diff --git a/src/spec/paths.ts b/src/spec/paths.ts index 70081ab..bffd410 100644 --- a/src/spec/paths.ts +++ b/src/spec/paths.ts @@ -1,3 +1,4 @@ import { empire } from './paths/empire'; +import { body } from './paths/body'; -export const paths = { ...empire }; +export const paths = { ...empire, ...body }; diff --git a/src/spec/paths/body.ts b/src/spec/paths/body.ts new file mode 100644 index 0000000..570c402 --- /dev/null +++ b/src/spec/paths/body.ts @@ -0,0 +1,22 @@ +import { response200, response500, security } from '../chunks'; + +export const body = { + '/v2/body/get_status': { + post: { + ...security(), + + responses: { + ...response200('Returns information about the current state of the empire.', { + type: 'object', + required: ['empire', 'body'], + properties: { + server: { $ref: '#/components/schemas/server_status' }, + empire: { $ref: '#/components/schemas/empire_status' }, + body: { $ref: '#/components/schemas/body_status' }, + }, + }), + ...response500(), + }, + }, + }, +}; diff --git a/src/spec/paths/empire.ts b/src/spec/paths/empire.ts index 4a4782f..f9a3222 100644 --- a/src/spec/paths/empire.ts +++ b/src/spec/paths/empire.ts @@ -1,6 +1,35 @@ import { requestBodySchema, response200, response500, security, statusSchema } from '../chunks'; export const empire = { + '/v2/empire/is_name_available': { + post: { + responses: { + ...response200( + 'Returns a 1 if the name is available, or a throws an exception if it is not.', + { type: 'integer', enum: [1, 0] } + ), + ...response500(), + }, + + ...requestBodySchema({ + type: 'object', + required: ['name'], + properties: { name: { type: 'string' } }, + }), + }, + }, + + '/v2/empire/logout': { + post: { + ...security(), + + responses: { + ...response200('Ends a session. Returns 1.', { type: 'integer', enum: [1] }), + ...response500(), + }, + }, + }, + '/v2/empire/login': { post: { responses: { @@ -24,46 +53,341 @@ export const empire = { }, }, - '/v2/empire/view_boosts': { + '/v2/empire/fetch_captcha': { + post: { + responses: { + ...response200( + "Retrieves a captcha that is required in order to call the create method. Display the resulting captcha in your creation form and then call create with the user's response.", + { + type: 'object', + required: ['guid', 'url'], + properties: { guid: { type: 'string' }, url: { type: 'string' } }, + } + ), + ...response500(), + }, + }, + }, + + '/v2/empire/create': { + post: { + responses: { + ...response200('Creates a new empire and then returns an empire_id.', { type: 'string' }), + ...response500(), + }, + + ...requestBodySchema({ + type: 'object', + required: ['name', 'password', 'password1', 'captcha_guid', 'captcha_solution'], + properties: { + name: { type: 'string' }, + password: { type: 'string' }, + password1: { type: 'string' }, + captcha_guid: { type: 'string' }, + captcha_solution: { type: 'string' }, + email: { type: 'string' }, + invite_code: { type: 'string' }, + }, + }), + }, + }, + + '/v2/empire/found': { + post: { + responses: { + ...response200( + "Set up an empire on it's new home world. Once this method is called, the species can no longer be modified.", + { + type: 'object', + required: ['session_id', 'welcome_message_id', 'status'], + properties: { + session_id: { type: 'string' }, + welcome_message_id: { type: 'string' }, + status: statusSchema(), + }, + } + ), + ...response500(), + }, + + ...requestBodySchema({ + type: 'object', + required: ['empire_id', 'api_key'], + properties: { + empire_id: { type: 'string' }, + api_key: { type: 'string' }, + invite_code: { type: 'string' }, + }, + }), + }, + }, + + '/v2/empire/get_friend_invite_url': { post: { ...security(), responses: { - ...response200('Shows the dates boosts have expired or will expire', { - type: 'object', - properties: { - boosts: { - type: 'object', - properties: { - spy_training: { type: 'string' }, - ore: { type: 'string' }, - water: { type: 'string' }, - storage: { type: 'string' }, - food: { type: 'string' }, - happiness: { type: 'string' }, - building: { type: 'string' }, - energy: { type: 'string' }, + ...response200( + 'Returns a URL that can be pasted into a blog, forum, or whatever to invite friends.', + { + type: 'object', + required: ['referral_url', 'status'], + properties: { referral_url: { type: 'string' }, status: statusSchema() }, + } + ), + ...response500(), + }, + }, + }, + + '/v2/empire/invite_friend': { + post: { + ...security(), + + responses: { + ...response200( + 'Send an invitation code to a friend so that they can start in the same zone as your empire.', + { + type: 'object', + required: ['status'], + properties: { + sent: { type: 'array', items: { type: 'string' } }, + not_sent: { + type: 'array', + items: { + type: 'object', + required: ['address', 'reason'], + properties: { address: { type: 'string' }, reason: { type: 'array' } }, + }, }, - required: [ - 'spy_training', - 'ore', - 'water', - 'storage', - 'food', - 'happiness', - 'building', - 'energy', - ], + status: statusSchema(), }, - status: statusSchema(), + } + ), + ...response500(), + }, + + ...requestBodySchema({ + type: 'object', + required: ['email'], + properties: { email: { type: 'string' }, custom_message: { type: 'string' } }, + }), + }, + }, + + '/v2/empire/get_status': { + post: { + ...security(), + + responses: { + ...response200('Returns information about the current state of the empire.', { + type: 'object', + required: ['empire', 'body'], + properties: { + server: { $ref: '#/components/schemas/server_status' }, + empire: { $ref: '#/components/schemas/empire_status' }, }, - required: ['boosts', 'status'], }), ...response500(), }, }, }, + '/v2/empire/view_profile': { + post: { + ...security(), + + responses: { + ...response200( + "Provides a list of the editable properties of the current empire's profile. See also the edit_profile and view_public_profile methods.", + { + type: 'object', + required: ['profile', 'status'], + properties: { + profile: { + type: 'object', + required: [ + 'description', + 'status_message', + 'medals', + 'city', + 'country', + 'notes', + 'skype', + 'player_name', + 'skip_happiness_warnings', + 'skip_resource_warnings', + 'skip_pollution_warnings', + 'skip_medal_messages', + 'skip_facebook_wall_posts', + 'skip_found_nothing', + 'skip_excavator_resources', + 'skip_excavator_glyph', + 'skip_excavator_plan', + 'skip_spy_recovery', + 'skip_probe_detected', + 'skip_attack_messages', + 'skip_incoming_ships', + 'email', + 'sitter_password', + ], + properties: { + description: { type: 'string' }, + status_message: { type: 'string' }, + medals: { + '{medal_id}': { + name: { type: 'string' }, + image: { type: 'string' }, + date: { type: 'string', format: 'date-time' }, + public: { type: 'integer', enum: [1, 0], times_earned: { type: 'integer' } }, + }, + }, + city: { type: 'string' }, + country: { type: 'string' }, + notes: { type: 'string' }, + skype: { type: 'string' }, + player_name: { type: 'string' }, + skip_happiness_warnings: { type: 'integer', enum: [1, 0] }, + skip_resource_warnings: { type: 'integer', enum: [1, 0] }, + skip_pollution_warnings: { type: 'integer', enum: [1, 0] }, + skip_medal_messages: { type: 'integer', enum: [1, 0] }, + skip_facebook_wall_posts: { type: 'integer', enum: [1, 0] }, + skip_found_nothing: { type: 'integer', enum: [1, 0] }, + skip_excavator_resources: { type: 'integer', enum: [1, 0] }, + skip_excavator_glyph: { type: 'integer', enum: [1, 0] }, + skip_excavator_plan: { type: 'integer', enum: [1, 0] }, + skip_spy_recovery: { type: 'integer', enum: [1, 0] }, + skip_probe_detected: { type: 'integer', enum: [1, 0] }, + skip_attack_messages: { type: 'integer', enum: [1, 0] }, + skip_incoming_ships: { type: 'integer', enum: [1, 0] }, + email: { type: 'string', format: 'email' }, + sitter_password: { type: 'string' }, + }, + status: statusSchema(), + }, + }, + } + ), + ...response500(), + }, + }, + }, + + '/v2/empire/edit_profile': { + post: { + ...security(), + + responses: { + ...response200( + 'Edits properties of an empire. Returns the view_profile method. See also the view_profile and view_public_profile methods.', + { + type: 'object', + required: ['profile', 'status'], + properties: { + profile: { + type: 'object', + required: [ + 'description', + 'status_message', + 'medals', + 'city', + 'country', + 'notes', + 'skype', + 'player_name', + 'skip_happiness_warnings', + 'skip_resource_warnings', + 'skip_pollution_warnings', + 'skip_medal_messages', + 'skip_facebook_wall_posts', + 'skip_found_nothing', + 'skip_excavator_resources', + 'skip_excavator_glyph', + 'skip_excavator_plan', + 'skip_spy_recovery', + 'skip_probe_detected', + 'skip_attack_messages', + 'skip_incoming_ships', + 'email', + 'sitter_password', + ], + properties: { + description: { type: 'string' }, + status_message: { type: 'string' }, + medals: { + '{medal_id}': { + name: { type: 'string' }, + image: { type: 'string' }, + date: { type: 'string', format: 'date-time' }, + public: { type: 'integer', enum: [1, 0], times_earned: { type: 'integer' } }, + }, + }, + city: { type: 'string' }, + country: { type: 'string' }, + notes: { type: 'string' }, + skype: { type: 'string' }, + player_name: { type: 'string' }, + skip_happiness_warnings: { type: 'integer', enum: [1, 0] }, + skip_resource_warnings: { type: 'integer', enum: [1, 0] }, + skip_pollution_warnings: { type: 'integer', enum: [1, 0] }, + skip_medal_messages: { type: 'integer', enum: [1, 0] }, + skip_facebook_wall_posts: { type: 'integer', enum: [1, 0] }, + skip_found_nothing: { type: 'integer', enum: [1, 0] }, + skip_excavator_resources: { type: 'integer', enum: [1, 0] }, + skip_excavator_glyph: { type: 'integer', enum: [1, 0] }, + skip_excavator_plan: { type: 'integer', enum: [1, 0] }, + skip_spy_recovery: { type: 'integer', enum: [1, 0] }, + skip_probe_detected: { type: 'integer', enum: [1, 0] }, + skip_attack_messages: { type: 'integer', enum: [1, 0] }, + skip_incoming_ships: { type: 'integer', enum: [1, 0] }, + email: { type: 'string', format: 'email' }, + sitter_password: { type: 'string' }, + }, + status: statusSchema(), + }, + }, + } + ), + ...response500(), + }, + + ...requestBodySchema({ + type: 'object', + required: ['profile'], + properties: { + profile: { + type: 'object', + properties: { + description: { type: 'string' }, + status_message: { type: 'string' }, + public_medals: { type: 'array', items: { type: 'number' } }, + city: { type: 'string' }, + country: { type: 'string' }, + notes: { type: 'string' }, + skype: { type: 'string' }, + player_name: { type: 'string' }, + skip_happiness_warnings: { type: 'integer', enum: [1, 0] }, + skip_resource_warnings: { type: 'integer', enum: [1, 0] }, + skip_pollution_warnings: { type: 'integer', enum: [1, 0] }, + skip_medal_messages: { type: 'integer', enum: [1, 0] }, + skip_facebook_wall_posts: { type: 'integer', enum: [1, 0] }, + skip_found_nothing: { type: 'integer', enum: [1, 0] }, + skip_excavator_resources: { type: 'integer', enum: [1, 0] }, + skip_excavator_glyph: { type: 'integer', enum: [1, 0] }, + skip_excavator_plan: { type: 'integer', enum: [1, 0] }, + skip_spy_recovery: { type: 'integer', enum: [1, 0] }, + skip_probe_detected: { type: 'integer', enum: [1, 0] }, + skip_attack_messages: { type: 'integer', enum: [1, 0] }, + skip_incoming_ships: { type: 'integer', enum: [1, 0] }, + email: { type: 'string', format: 'email' }, + sitter_password: { type: 'string' }, + }, + }, + }, + }), + }, + }, + '/v2/empire/view_public_profile': { post: { ...security(), @@ -229,4 +553,420 @@ export const empire = { }), }, }, + + '/v2/empire/send_password_reset_message': { + post: { + responses: { + ...response200( + 'Starts a password recovery process by sending an email with a recovery key.', + { + type: 'object', + properties: { sent: { type: 'integer', enum: [1] } }, + required: ['sent'], + } + ), + ...response500(), + }, + + ...requestBodySchema({ + type: 'object', + required: ['empire_id', 'empire_name', 'email'], + properties: { + empire_id: { type: 'number' }, + empire_name: { type: 'string' }, + email: { type: 'string' }, + }, + }), + }, + }, + + '/v2/empire/reset_password': { + post: { + responses: { + ...response200( + 'Change the empire password that has been forgotten. Returns the same response as `login` if successful.', + { + type: 'object', + properties: { session_id: { type: 'string' }, status: statusSchema() }, + required: ['session_id', 'status'], + } + ), + ...response500(), + }, + + ...requestBodySchema({ + type: 'object', + required: ['reset_key', 'password1', 'password2', 'api_key'], + properties: { + reset_key: { type: 'number' }, + password1: { type: 'string' }, + password2: { type: 'string' }, + api_key: { type: 'string' }, + }, + }), + }, + }, + + '/v2/empire/change_password': { + post: { + ...security(), + + responses: { + ...response200('Change the empire password.', { + type: 'object', + properties: { status: statusSchema() }, + required: ['status'], + }), + ...response500(), + }, + + ...requestBodySchema({ + type: 'object', + required: ['password1', 'password2'], + properties: { password1: { type: 'string' }, password2: { type: 'string' } }, + }), + }, + }, + + '/v2/empire/find': { + post: { + ...security(), + + responses: { + ...response200( + 'Find an empire by name. Returns a hash reference containing empire ids and empire names.', + { + type: 'object', + properties: { + empires: { + type: 'array', + items: { + type: 'object', + properties: { id: { type: 'number' }, name: { type: 'string' } }, + required: ['id', 'name'], + }, + }, + status: statusSchema(), + }, + required: ['empires', 'status'], + } + ), + ...response500(), + }, + + ...requestBodySchema({ + type: 'object', + required: ['name'], + properties: { name: { type: 'string' } }, + }), + }, + }, + + '/v2/empire/set_status_message': { + post: { + ...security(), + + responses: { + ...response200( + 'Sets the empire status message. Similar to what you might put on your Facebook wall, or in a tweet, but about your empire.', + { type: 'object', properties: { status: statusSchema() }, required: ['status'] } + ), + ...response500(), + }, + + ...requestBodySchema({ + type: 'object', + required: ['message'], + properties: { message: { type: 'string' } }, + }), + }, + }, + + '/v2/empire/view_boosts': { + post: { + ...security(), + + responses: { + ...response200('Shows the dates boosts have expired or will expire', { + type: 'object', + properties: { + boosts: { + type: 'object', + properties: { + spy_training: { type: 'string', format: 'date-time' }, + ore: { type: 'string', format: 'date-time' }, + water: { type: 'string', format: 'date-time' }, + storage: { type: 'string', format: 'date-time' }, + food: { type: 'string', format: 'date-time' }, + happiness: { type: 'string', format: 'date-time' }, + building: { type: 'string', format: 'date-time' }, + energy: { type: 'string', format: 'date-time' }, + }, + required: [ + 'spy_training', + 'ore', + 'water', + 'storage', + 'food', + 'happiness', + 'building', + 'energy', + ], + }, + status: statusSchema(), + }, + required: ['boosts', 'status'], + }), + ...response500(), + }, + }, + }, + + '/v2/empire/boost_storage': { + post: { + ...security(), + + responses: { + ...response200( + 'Spends 5 essentia, and boosts storage (all 5 types) on all planets for 7 days. If a boost is already underway, calling again will add 7 more days.', + { + type: 'object', + properties: { + storage_boost: { type: 'string', format: 'date-time' }, + status: statusSchema(), + }, + required: ['storage_boost', 'status'], + } + ), + ...response500(), + }, + + ...requestBodySchema({ + type: 'object', + required: [], + properties: { weeks: { type: 'integer', minimum: 1 } }, + }), + }, + }, + + '/v2/empire/boost_food': { + post: { + ...security(), + + responses: { + ...response200('', { + type: 'object', + properties: { + food_boost: { type: 'string', format: 'date-time' }, + status: statusSchema(), + }, + required: ['food_boost', 'status'], + }), + ...response500(), + }, + + ...requestBodySchema({ + type: 'object', + required: [], + properties: { weeks: { type: 'integer', minimum: 1 } }, + }), + }, + }, + + '/v2/empire/boost_water': { + post: { + ...security(), + + responses: { + ...response200('', { + type: 'object', + properties: { + water_boost: { type: 'string', format: 'date-time' }, + status: statusSchema(), + }, + required: ['water_boost', 'status'], + }), + ...response500(), + }, + + ...requestBodySchema({ + type: 'object', + required: [], + properties: { weeks: { type: 'integer', minimum: 1 } }, + }), + }, + }, + + '/v2/empire/boost_energy': { + post: { + ...security(), + + responses: { + ...response200('', { + type: 'object', + properties: { + energy_boost: { type: 'string', format: 'date-time' }, + status: statusSchema(), + }, + required: ['energy_boost', 'status'], + }), + ...response500(), + }, + + ...requestBodySchema({ + type: 'object', + required: [], + properties: { weeks: { type: 'integer', minimum: 1 } }, + }), + }, + }, + + '/v2/empire/boost_ore': { + post: { + ...security(), + + responses: { + ...response200('', { + type: 'object', + properties: { + ore_boost: { type: 'string', format: 'date-time' }, + status: statusSchema(), + }, + required: ['ore_boost', 'status'], + }), + ...response500(), + }, + + ...requestBodySchema({ + type: 'object', + required: [], + properties: { weeks: { type: 'integer', minimum: 1 } }, + }), + }, + }, + + '/v2/empire/boost_happiness': { + post: { + ...security(), + + responses: { + ...response200('', { + type: 'object', + properties: { + happiness_boost: { type: 'string', format: 'date-time' }, + status: statusSchema(), + }, + required: ['happiness_boost', 'status'], + }), + ...response500(), + }, + + ...requestBodySchema({ + type: 'object', + required: [], + properties: { weeks: { type: 'integer', minimum: 1 } }, + }), + }, + }, + + '/v2/empire/boost_building': { + post: { + ...security(), + + responses: { + ...response200('', { + type: 'object', + properties: { + building_boost: { type: 'string', format: 'date-time' }, + status: statusSchema(), + }, + required: ['building_boost', 'status'], + }), + ...response500(), + }, + + ...requestBodySchema({ + type: 'object', + required: [], + properties: { weeks: { type: 'integer', minimum: 1 } }, + }), + }, + }, + + '/v2/empire/boost_spy_training': { + post: { + ...security(), + + responses: { + ...response200('', { + type: 'object', + properties: { + spy_training_boost: { type: 'string', format: 'date-time' }, + status: statusSchema(), + }, + required: ['spy_training_boost', 'status'], + }), + ...response500(), + }, + + ...requestBodySchema({ + type: 'object', + required: [], + properties: { weeks: { type: 'integer', minimum: 1 } }, + }), + }, + }, + + '/v2/empire/enable_self_destruct': { + post: { + ...security(), + + responses: { + ...response200( + 'Enables a destruction countdown of 24 hours. Sometime after the timer runs out, the empire will vaporize.', + { type: 'object', properties: { status: statusSchema() }, required: ['status'] } + ), + ...response500(), + }, + }, + }, + + '/v2/empire/disable_self_destruct': { + post: { + ...security(), + + responses: { + ...response200('Disables the self distruction countdown.', { + type: 'object', + properties: { status: statusSchema() }, + required: ['status'], + }), + ...response500(), + }, + }, + }, + + '/v2/empire/redeem_essentia_code': { + post: { + ...security(), + + responses: { + ...response200( + "Redeems an essentia code and applies the essentia to the empire's balance.", + { + type: 'object', + properties: { amount: { type: 'number' }, status: statusSchema() }, + required: ['amount', 'status'], + } + ), + ...response500(), + }, + + ...requestBodySchema({ + type: 'object', + required: ['code'], + properties: { code: { type: 'string' } }, + }), + }, + }, };