Skip to content

Commit

Permalink
Fix #49
Browse files Browse the repository at this point in the history
  • Loading branch information
Blacksmoke16 committed Jan 20, 2019
1 parent 99a538e commit edada5f
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 13 deletions.
Binary file modified bin/GESI-linux-x86_64
Binary file not shown.
13 changes: 8 additions & 5 deletions src/parser/eve_swagger.cr
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ module EveSwagger
version: {type: String, setter: false},
)

def initialize(@method : String, @description : String, schema : Schema | Nil, @parameters : Array(Parameter), @path : String, @scope : String | Nil, @summary : String, endpoint_name : String, @version : String)
def initialize(@method : String, @description : String, schema : Schema?, @parameters : Array(Parameter), @path : String, @scope : String?, @summary : String, endpoint_name : String, @version : String)
@description = @description.match(/([\w ]+)[^\n\-\-\-]+/).not_nil![0]
@headers = get_headers(schema)

Expand Down Expand Up @@ -265,10 +265,13 @@ module EveSwagger

@parameters.sort_by! { |p| p.required ? 0 : 1 }

# Remove character/corporation/alliance_id param if they are not one of the endpoints that can be arbitrary
@parameters.delete @parameters.find { |p| p.name == "character_id" } unless %w(characters_character characters_character_corporationhistory).includes? endpoint_name
@parameters.delete @parameters.find { |p| p.name == "corporation_id" } unless %w(corporations_corporation loyalty_stores_corporation_offers corporations_corporation_alliancehistory).includes? endpoint_name
@parameters.delete @parameters.find { |p| p.name == "alliance_id" } unless endpoint_name == "alliances_alliance"
# Remove character/corporation/alliance_id param if they are an authed endpoint
# They will be auto filled in based on the authing character
if scope
@parameters.delete @parameters.find { |p| p.name == "character_id" }
@parameters.delete @parameters.find { |p| p.name == "corporation_id" }
@parameters.delete @parameters.find { |p| p.name == "alliance_id" }
end

# Add name parameter if function requires auth
name = Parameter.from_json({name: "name", in: "parameters", type: "string", description: "Name of the character used for auth. If none is given, defaults to MAIN_CHARACTER."}.to_json)
Expand Down
28 changes: 28 additions & 0 deletions src/script/endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,13 @@ const ENDPOINTS = {
"method": "GET",
"path": "/{version}/alliances/{alliance_id}/corporations/",
"parameters": [
{
"description": "An EVE alliance ID",
"in": "path",
"name": "alliance_id",
"type": "number",
"required": true
},
{
"description": "Boolean if column headings should be listed or not. Default: true",
"in": "parameters",
Expand Down Expand Up @@ -169,6 +176,13 @@ const ENDPOINTS = {
"method": "GET",
"path": "/{version}/alliances/{alliance_id}/icons/",
"parameters": [
{
"description": "An EVE alliance ID",
"in": "path",
"name": "alliance_id",
"type": "number",
"required": true
},
{
"description": "Boolean if column headings should be listed or not. Default: true",
"in": "parameters",
Expand Down Expand Up @@ -3080,6 +3094,13 @@ const ENDPOINTS = {
"method": "GET",
"path": "/{version}/corporations/{corporation_id}/icons/",
"parameters": [
{
"description": "An EVE corporation ID",
"in": "path",
"name": "corporation_id",
"type": "number",
"required": true
},
{
"description": "Boolean if column headings should be listed or not. Default: true",
"in": "parameters",
Expand Down Expand Up @@ -7558,6 +7579,13 @@ const ENDPOINTS = {
"method": "GET",
"path": "/{version}/characters/{character_id}/portrait/",
"parameters": [
{
"description": "An EVE character ID",
"in": "path",
"name": "character_id",
"type": "number",
"required": true
},
{
"description": "Boolean if column headings should be listed or not. Default: true",
"in": "parameters",
Expand Down
24 changes: 16 additions & 8 deletions src/script/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,28 @@ function alliances_alliance_contacts_labels(name: string, opt_headers: boolean,

/**
* List all current member corporations of an alliance
* @param {number} alliance_id (Required) An EVE alliance ID
* @param {boolean} opt_headers Boolean if column headings should be listed or not. Default: true
* @param {string} version Which ESI version to use for the request. Default: Current ESI latest stable version.
* @return List of corporation IDs
* @customfunction
*/
function alliances_alliance_corporations(opt_headers: boolean, version: string): any[][] {
return parseData_('alliances_alliance_corporations',{opt_headers:opt_headers,version:version})
function alliances_alliance_corporations(alliance_id: number, opt_headers: boolean, version: string): any[][] {
if(!alliance_id) throw buildError_({body: 'alliance_id is required', code: 400, method: 'alliances_alliance_corporations'});
return parseData_('alliances_alliance_corporations',{alliance_id:alliance_id,opt_headers:opt_headers,version:version})
}

/**
* Get the icon urls for a alliance
* @param {number} alliance_id (Required) An EVE alliance ID
* @param {boolean} opt_headers Boolean if column headings should be listed or not. Default: true
* @param {string} version Which ESI version to use for the request. Default: Current ESI latest stable version.
* @return Icon URLs for the given alliance id and server
* @customfunction
*/
function alliances_alliance_icons(opt_headers: boolean, version: string): any[][] {
return parseData_('alliances_alliance_icons',{opt_headers:opt_headers,version:version})
function alliances_alliance_icons(alliance_id: number, opt_headers: boolean, version: string): any[][] {
if(!alliance_id) throw buildError_({body: 'alliance_id is required', code: 400, method: 'alliances_alliance_icons'});
return parseData_('alliances_alliance_icons',{alliance_id:alliance_id,opt_headers:opt_headers,version:version})
}

/**
Expand Down Expand Up @@ -711,13 +715,15 @@ function corporations_corporation_fw_stats(name: string, opt_headers: boolean, v

/**
* Get the icon urls for a corporation
* @param {number} corporation_id (Required) An EVE corporation ID
* @param {boolean} opt_headers Boolean if column headings should be listed or not. Default: true
* @param {string} version Which ESI version to use for the request. Default: Current ESI latest stable version.
* @return Urls for icons for the given corporation id and server
* @customfunction
*/
function corporations_corporation_icons(opt_headers: boolean, version: string): any[][] {
return parseData_('corporations_corporation_icons',{opt_headers:opt_headers,version:version})
function corporations_corporation_icons(corporation_id: number, opt_headers: boolean, version: string): any[][] {
if(!corporation_id) throw buildError_({body: 'corporation_id is required', code: 400, method: 'corporations_corporation_icons'});
return parseData_('corporations_corporation_icons',{corporation_id:corporation_id,opt_headers:opt_headers,version:version})
}

/**
Expand Down Expand Up @@ -1801,13 +1807,15 @@ function characters_character_orders(name: string, opt_headers: boolean, version

/**
* Get portrait urls for a character
* @param {number} character_id (Required) An EVE character ID
* @param {boolean} opt_headers Boolean if column headings should be listed or not. Default: true
* @param {string} version Which ESI version to use for the request. Default: Current ESI latest stable version.
* @return Public data for the given character
* @customfunction
*/
function characters_character_portrait(opt_headers: boolean, version: string): any[][] {
return parseData_('characters_character_portrait',{opt_headers:opt_headers,version:version})
function characters_character_portrait(character_id: number, opt_headers: boolean, version: string): any[][] {
if(!character_id) throw buildError_({body: 'character_id is required', code: 400, method: 'characters_character_portrait'});
return parseData_('characters_character_portrait',{character_id:character_id,opt_headers:opt_headers,version:version})
}

/**
Expand Down

0 comments on commit edada5f

Please sign in to comment.