Something went wrong. Try again.
OpenAPI 3.0 compliant spec for TLE Community.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542import { operation, buildingBase, buildingCommonMethods, buildingView, requestBodySchema, response200, response500, security, statusSchema, tags,} from '../../chunks.ts';
const base = buildingBase('Embassy');
const buildingIdRequestBody = requestBodySchema({ type: 'object', required: ['building_id'], properties: { building_id: { type: 'integer', description: 'The unique id of the building.' } },});
const optionalMessageRequestBody = (extraRequired: string[] = [], extraProperties: object = {}) => requestBodySchema({ type: 'object', required: ['building_id', ...extraRequired], properties: { building_id: { type: 'integer', description: 'The unique id of the building.' }, message: { type: 'string', description: 'An optional personalised message included with the action.', }, ...extraProperties, }, });
// This empire's alliance, as returned nested under `alliance_status` on `view` and (flattened// alongside `status`) by get_alliance_status.const allianceStatusProperties = { id: { type: 'integer' }, name: { type: 'string' }, members: { type: 'array', items: { type: 'object', properties: { empire_id: { type: 'integer' }, name: { type: 'string' } }, }, }, leader_id: { type: 'integer' }, forum_uri: { type: 'string' }, description: { type: 'string' }, announcements: { type: 'string' }, date_created: { type: 'string' },};
// This is the module where alliance *management* (create/dissolve/invite/leave/stash/// propositions) lives, per the docs — the Alliance module itself only exposes read-only lookups.export const embassy = { ...buildingCommonMethods(base), ...buildingView(base, { alliance_status: { type: 'object', description: 'Present only when this empire is in an alliance.', properties: allianceStatusProperties, }, }),
[`${base}/create_alliance`]: { post: { ...tags(base), ...security(), ...operation('Create alliance.', 'Creates a new alliance with this empire as leader.'), ...requestBodySchema({ type: 'object', required: ['building_id', 'name'], properties: { building_id: { type: 'integer', description: 'The unique id of the building.' }, name: { type: 'string', minLength: 3, maxLength: 30, description: 'A unique alliance name, 3-30 characters, no profanity or restricted characters.', }, }, }), responses: { ...response200('Creates a new alliance with this empire as leader.', { type: 'object', required: ['status'], properties: { status: statusSchema() }, }), ...response500(), }, }, },
[`${base}/get_alliance_status`]: { post: { ...tags(base), ...security(), ...operation('Get alliance status.', "Returns this empire's alliance data."), ...buildingIdRequestBody, responses: { ...response200("Returns this empire's alliance data.", { type: 'object', required: ['status'], properties: { ...allianceStatusProperties, status: statusSchema() }, }), ...response500(), }, }, },
[`${base}/dissolve_alliance`]: { post: { ...tags(base), ...security(), ...operation( 'Dissolve alliance.', 'Leader-only. Disbands the alliance and converts its space stations to asteroids.' ), ...buildingIdRequestBody, responses: { ...response200( 'Leader-only. Disbands the alliance and converts its space stations to asteroids.', { type: 'object', required: ['status'], properties: { status: statusSchema() } } ), ...response500(), }, }, },
[`${base}/update_alliance`]: { post: { ...tags(base), ...security(), ...operation('Update alliance.', 'Leader-only. Updates alliance metadata.'), ...requestBodySchema({ type: 'object', required: ['building_id', 'params'], properties: { building_id: { type: 'integer', description: 'The unique id of the building.' }, params: { type: 'object', description: 'The alliance properties to update. Any or all of forum_uri, description, announcements.', properties: { forum_uri: { type: 'string' }, description: { type: 'string' }, announcements: { type: 'string' }, }, }, }, }), responses: { ...response200('Leader-only. Updates alliance metadata.', { type: 'object', required: ['status'], properties: { status: statusSchema() }, }), ...response500(), }, }, },
[`${base}/send_invite`]: { post: { ...tags(base), ...security(), ...operation('Send invite.', 'Leader-only. Invites an empire to join the alliance.'), ...optionalMessageRequestBody(['invitee_id'], { invitee_id: { type: 'integer', description: 'The unique id of the empire to invite.' }, }), responses: { ...response200('Leader-only. Invites an empire to join the alliance.', { type: 'object', required: ['status'], properties: { status: statusSchema() }, }), ...response500(), }, }, },
[`${base}/withdraw_invite`]: { post: { ...tags(base), ...security(), ...operation('Withdraw invite.', 'Leader-only. Withdraws a pending invite.'), ...optionalMessageRequestBody(['invite_id'], { invite_id: { type: 'integer', description: 'The unique id of the invitation.' }, }), responses: { ...response200('Leader-only. Withdraws a pending invite.', { type: 'object', required: ['status'], properties: { status: statusSchema() }, }), ...response500(), }, }, },
[`${base}/get_pending_invites`]: { post: { ...tags(base), ...security(), ...operation( 'Get pending invites.', 'Leader-only. Lists outstanding invites sent by the alliance.' ), ...buildingIdRequestBody, responses: { ...response200('Leader-only. Lists outstanding invites sent by the alliance.', { type: 'object', required: ['invites', 'status'], properties: { invites: { type: 'array', items: { type: 'object', properties: { id: { type: 'integer' }, name: { type: 'string' }, empire_id: { type: 'integer' }, }, }, }, status: statusSchema(), }, }), ...response500(), }, }, },
[`${base}/accept_invite`]: { post: { ...tags(base), ...security(), ...operation('Accept invite.', 'Accepts an invite to join an alliance.'), ...optionalMessageRequestBody(['invite_id'], { invite_id: { type: 'integer', description: 'The unique id of the invitation.' }, }), responses: { ...response200('Accepts an invite to join an alliance.', { type: 'object', required: ['status'], properties: { status: statusSchema() }, }), ...response500(), }, }, },
[`${base}/reject_invite`]: { post: { ...tags(base), ...security(), ...operation('Reject invite.', 'Declines an invite to join an alliance.'), ...optionalMessageRequestBody(['invite_id'], { invite_id: { type: 'integer', description: 'The unique id of the invitation.' }, }), responses: { ...response200('Declines an invite to join an alliance.', { type: 'object', required: ['status'], properties: { status: statusSchema() }, }), ...response500(), }, }, },
[`${base}/get_my_invites`]: { post: { ...tags(base), ...security(), ...operation('Get my invites.', 'Lists invites this empire has received.'), ...buildingIdRequestBody, responses: { ...response200('Lists invites this empire has received.', { type: 'object', required: ['invites', 'status'], properties: { invites: { type: 'array', items: { type: 'object', properties: { id: { type: 'integer' }, name: { type: 'string' }, alliance_id: { type: 'integer' }, }, }, }, status: statusSchema(), }, }), ...response500(), }, }, },
[`${base}/leave_alliance`]: { post: { ...tags(base), ...security(), ...operation('Leave alliance.', 'Leaves the current alliance.'), ...optionalMessageRequestBody(), responses: { ...response200('Leaves the current alliance.', { type: 'object', required: ['status'], properties: { status: statusSchema() }, }), ...response500(), }, }, },
[`${base}/expel_member`]: { post: { ...tags(base), ...security(), ...operation('Expel member.', 'Leader-only. Removes a member from the alliance.'), ...optionalMessageRequestBody(['empire_id'], { empire_id: { type: 'integer', description: 'The unique id of the member to remove.' }, }), responses: { ...response200('Leader-only. Removes a member from the alliance.', { type: 'object', required: ['status'], properties: { status: statusSchema() }, }), ...response500(), }, }, },
[`${base}/assign_alliance_leader`]: { post: { ...tags(base), ...security(), ...operation( 'Assign alliance leader.', 'Leader-only. Transfers alliance leadership to another current member.' ), ...requestBodySchema({ type: 'object', required: ['building_id', 'new_leader_id'], properties: { building_id: { type: 'integer', description: 'The unique id of the building.' }, new_leader_id: { type: 'integer', description: 'The unique id of the empire to make leader. Must already be a member of the alliance.', }, }, }), responses: { ...response200('Leader-only. Transfers alliance leadership to another current member.', { type: 'object', required: ['status'], properties: { status: statusSchema() }, }), ...response500(), }, }, },
[`${base}/view_stash`]: { post: { ...tags(base), ...security(), ...operation('View stash.', "Returns the alliance stash's contents."), ...buildingIdRequestBody, responses: { ...response200("Returns the alliance stash's contents.", { type: 'object', required: ['stash', 'stored', 'max_exchange_size', 'exchanges_remaining_today', 'status'], properties: { stash: { type: 'object', description: "The alliance stash's contents, keyed by resource name.", additionalProperties: { type: 'integer' }, }, stored: { type: 'object', description: "The calling planet's own storable resources, keyed by resource name.", additionalProperties: { type: 'integer' }, }, max_exchange_size: { type: 'integer' }, exchanges_remaining_today: { type: 'integer' }, status: statusSchema(), }, }), ...response500(), }, }, },
[`${base}/donate_to_stash`]: { post: { ...tags(base), ...security(), ...operation('Donate to stash.', 'Donates resources to the alliance stash.'), ...requestBodySchema({ type: 'object', required: ['building_id', 'donation'], properties: { building_id: { type: 'integer', description: 'The unique id of the building.' }, donation: { type: 'object', description: 'Resource name to quantity, e.g. {"water": 4500, "bread": 5000}. Waste is not allowed.', additionalProperties: { type: 'integer' }, }, }, }), responses: { ...response200('Donates resources to the alliance stash.', { type: 'object', required: ['status'], properties: { status: statusSchema() }, }), ...response500(), }, }, },
[`${base}/exchange_with_stash`]: { post: { ...tags(base), ...security(), ...operation('Exchange with stash.', 'Exchanges resources with the alliance stash.'), ...requestBodySchema({ type: 'object', required: ['building_id', 'donation', 'request'], properties: { building_id: { type: 'integer', description: 'The unique id of the building.' }, donation: { type: 'object', description: 'Must equal request in total value. Waste is not allowed.', additionalProperties: { type: 'integer' }, }, request: { type: 'object', description: 'Resource name to quantity to pull from the stash. Total value must equal the donation total.', additionalProperties: { type: 'integer' }, }, }, }), responses: { ...response200('Exchanges resources with the alliance stash.', { type: 'object', required: ['status'], properties: { status: statusSchema() }, }), ...response500(), }, }, },
[`${base}/view_propositions`]: { post: { ...tags(base), ...security(), ...operation('View propositions.', 'Lists pending propositions the alliance is voting on.'), ...buildingIdRequestBody, responses: { ...response200('Lists pending propositions the alliance is voting on.', { type: 'object', required: ['propositions', 'status'], properties: { propositions: { type: 'array', items: { type: 'object', properties: { id: { type: 'integer' }, name: { type: 'string' }, description: { type: 'string' }, votes_needed: { type: 'integer' }, votes_yes: { type: 'integer' }, votes_no: { type: 'integer' }, status: { type: 'string' }, date_ends: { type: 'string' }, proposed_by: { type: 'object', properties: { id: { type: 'integer' }, name: { type: 'string' } }, }, my_vote: { type: 'integer', enum: [1, 0], description: 'Only present if this empire has voted.', }, }, }, }, status: statusSchema(), }, }), ...response500(), }, }, },
[`${base}/cast_vote`]: { post: { ...tags(base), ...security(), ...operation('Cast vote.', 'Casts a vote on a proposition. Throws 1018 if already voted.'), ...requestBodySchema({ type: 'object', required: ['building_id', 'proposition_id', 'vote'], properties: { building_id: { type: 'integer', description: 'The unique id of the building.' }, proposition_id: { type: 'integer', description: 'The id of the proposition being voted on. See view_propositions.', }, vote: { type: 'integer', enum: [1, 0], description: '1 for yes, 0 for no. Defaults to 0.', }, }, }), responses: { ...response200('Casts a vote on a proposition. Throws 1018 if already voted.', { type: 'object', required: ['status'], properties: { status: statusSchema() }, }), ...response500(), }, }, },};