Class: CLIENT

Inherits:
Object
  • Object
show all
Defined in:
lib/SWGOH/API/CLIENT/client.rb

Overview

The CLIENT class makes requests to api.swgoh.api

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCLIENT

Returns a new instance of CLIENT.



13
14
15
16
17
18
19
# File 'lib/SWGOH/API/CLIENT/client.rb', line 13

def initialize
  @language = SWGOH::API::LANGUAGE::ENG_US
  @enums = false
  @structure = false
  @access_token = nil
  @project = nil
end

Instance Attribute Details

#access_token=(value) ⇒ Object

Sets the attribute access_token

Parameters:

  • value

    the value to set the attribute access_token to.



11
12
13
# File 'lib/SWGOH/API/CLIENT/client.rb', line 11

def access_token=(value)
  @access_token = value
end

#enumsObject

Returns the value of attribute enums.



10
11
12
# File 'lib/SWGOH/API/CLIENT/client.rb', line 10

def enums
  @enums
end

#languageObject

Returns the value of attribute language.



10
11
12
# File 'lib/SWGOH/API/CLIENT/client.rb', line 10

def language
  @language
end

#projectObject

Returns the value of attribute project.



10
11
12
# File 'lib/SWGOH/API/CLIENT/client.rb', line 10

def project
  @project
end

#structureObject

Returns the value of attribute structure.



10
11
12
# File 'lib/SWGOH/API/CLIENT/client.rb', line 10

def structure
  @structure
end

Instance Method Details

#abilitiesJSON || nil

Returns:

  • (JSON || nil)


83
84
85
# File 'lib/SWGOH/API/CLIENT/client.rb', line 83

def abilities
  data_request(SWGOH::API::COLLECTION::ABILITY)
end

#authorize(username, password) ⇒ String | nil

Parameters:

  • username (String)
  • password (String)

Returns:

  • (String | nil)


29
30
31
32
33
34
35
36
# File 'lib/SWGOH/API/CLIENT/client.rb', line 29

def authorize(username, password)
  form = auth_request_form(username, password)
  path = "https://#{SWGOH::API::PATH::BASE}/#{SWGOH::API::PATH::AUTH_SIGNIN}"
  res = Net::HTTP.post_form(URI(path), form)
  return log_error(res) unless res.is_a?(Net::HTTPSuccess)

  @access_token = JSON.parse(res.body)['access_token']
end

#authorized?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/SWGOH/API/CLIENT/client.rb', line 22

def authorized?
  !@access_token.nil?
end

#battle_environmentsJSON || nil

Returns:

  • (JSON || nil)


88
89
90
# File 'lib/SWGOH/API/CLIENT/client.rb', line 88

def battle_environments
  data_request(SWGOH::API::COLLECTION::BATTLE_ENVIRONMENT)
end

#battle_targeting_rulesJSON || nil

Returns:

  • (JSON || nil)


93
94
95
# File 'lib/SWGOH/API/CLIENT/client.rb', line 93

def battle_targeting_rules
  data_request(SWGOH::API::COLLECTION::BATTLE_TARGETING_RULE)
end

#battlesJSON || nil

Returns:

  • (JSON || nil)


78
79
80
# File 'lib/SWGOH/API/CLIENT/client.rb', line 78

def battles
  request(SWGOH::API::PATH::BATTLES)
end

#categoriesJSON || nil

Returns:

  • (JSON || nil)


98
99
100
# File 'lib/SWGOH/API/CLIENT/client.rb', line 98

def categories
  data_request(SWGOH::API::COLLECTION::CATEGORY)
end

#challenge_stylesJSON || nil

Returns:

  • (JSON || nil)


108
109
110
# File 'lib/SWGOH/API/CLIENT/client.rb', line 108

def challenge_styles
  data_request(SWGOH::API::COLLECTION::CHALLENGE_STYLE)
end

#challengesJSON || nil

Returns:

  • (JSON || nil)


103
104
105
# File 'lib/SWGOH/API/CLIENT/client.rb', line 103

def challenges
  data_request(SWGOH::API::COLLECTION::CHALLENGE)
end

#effectsJSON || nil

Returns:

  • (JSON || nil)


113
114
115
# File 'lib/SWGOH/API/CLIENT/client.rb', line 113

def effects
  data_request(SWGOH::API::COLLECTION::EFFECT)
end

#environment_collectionsJSON || nil

Returns:

  • (JSON || nil)


118
119
120
# File 'lib/SWGOH/API/CLIENT/client.rb', line 118

def environment_collections
  data_request(SWGOH::API::COLLECTION::ENVIRONMENT_COLLECTION)
end

#equipmentJSON || nil

Returns:

  • (JSON || nil)


123
124
125
# File 'lib/SWGOH/API/CLIENT/client.rb', line 123

def equipment
  data_request(SWGOH::API::COLLECTION::EQUIPMENT)
end

#event_samplesJSON || nil

Returns:

  • (JSON || nil)


128
129
130
# File 'lib/SWGOH/API/CLIENT/client.rb', line 128

def event_samples
  data_request(SWGOH::API::COLLECTION::EVENT_SAMPLING)
end

#eventsJSON || nil

Returns:

  • (JSON || nil)


73
74
75
# File 'lib/SWGOH/API/CLIENT/client.rb', line 73

def events
  request(SWGOH::API::PATH::EVENTS)
end

#guild_exchange_itemsJSON || nil

Returns:

  • (JSON || nil)


133
134
135
# File 'lib/SWGOH/API/CLIENT/client.rb', line 133

def guild_exchange_items
  data_request(SWGOH::API::COLLECTION::GUILD_EXCHANGE_ITEM)
end

#guild_raidsJSON || nil

Returns:

  • (JSON || nil)


138
139
140
# File 'lib/SWGOH/API/CLIENT/client.rb', line 138

def guild_raids
  data_request(SWGOH::API::COLLECTION::GUILD_RAID)
end

#guilds(ally_codes) ⇒ JSON || nil

Parameters:

  • ally_codes (Array)

Returns:

  • (JSON || nil)


46
47
48
# File 'lib/SWGOH/API/CLIENT/client.rb', line 46

def guilds(ally_codes)
  ally_codes_request(SWGOH::API::PATH::GUILD, ally_codes)
end

#help_entriesJSON || nil

Returns:

  • (JSON || nil)


143
144
145
# File 'lib/SWGOH/API/CLIENT/client.rb', line 143

def help_entries
  data_request(SWGOH::API::COLLECTION::HELP_ENTRY)
end

#materialsJSON || nil

Returns:

  • (JSON || nil)


148
149
150
# File 'lib/SWGOH/API/CLIENT/client.rb', line 148

def materials
  data_request(SWGOH::API::COLLECTION::MATERIAL)
end

#player_titlesJSON || nil

Returns:

  • (JSON || nil)


153
154
155
# File 'lib/SWGOH/API/CLIENT/client.rb', line 153

def player_titles
  data_request(SWGOH::API::COLLECTION::PLAYER_TITLE)
end

#players(ally_codes) ⇒ JSON || nil

Parameters:

  • ally_codes (Array)

Returns:

  • (JSON || nil)


40
41
42
# File 'lib/SWGOH/API/CLIENT/client.rb', line 40

def players(ally_codes)
  ally_codes_request(SWGOH::API::PATH::PLAYER, ally_codes)
end

#power_up_bundlesJSON || nil

Returns:

  • (JSON || nil)


158
159
160
# File 'lib/SWGOH/API/CLIENT/client.rb', line 158

def power_up_bundles
  data_request(SWGOH::API::COLLECTION::POWER_UP_BUNDLE)
end

#raid_configsJSON || nil

Returns:

  • (JSON || nil)


163
164
165
# File 'lib/SWGOH/API/CLIENT/client.rb', line 163

def raid_configs
  data_request(SWGOH::API::COLLECTION::RAID_CONFIG)
end

#recipesJSON || nil

Returns:

  • (JSON || nil)


168
169
170
# File 'lib/SWGOH/API/CLIENT/client.rb', line 168

def recipes
  data_request(SWGOH::API::COLLECTION::RECIPE)
end

#requirementsJSON || nil

Returns:

  • (JSON || nil)


173
174
175
# File 'lib/SWGOH/API/CLIENT/client.rb', line 173

def requirements
  data_request(SWGOH::API::COLLECTION::REQUIREMENT)
end

#rosters(ally_codes) ⇒ JSON || nil

Parameters:

  • ally_codes (Array)

Returns:

  • (JSON || nil)


52
53
54
# File 'lib/SWGOH/API/CLIENT/client.rb', line 52

def rosters(ally_codes)
  ally_codes_request(SWGOH::API::PATH::ROSTER, ally_codes)
end

#skillsJSON || nil

Returns:

  • (JSON || nil)


178
179
180
# File 'lib/SWGOH/API/CLIENT/client.rb', line 178

def skills
  data_request(SWGOH::API::COLLECTION::SKILL)
end

#squadsJSON || nil

Returns:

  • (JSON || nil)


68
69
70
# File 'lib/SWGOH/API/CLIENT/client.rb', line 68

def squads
  request(SWGOH::API::PATH::SQUADS)
end

#starter_guildsJSON || nil

Returns:

  • (JSON || nil)


183
184
185
# File 'lib/SWGOH/API/CLIENT/client.rb', line 183

def starter_guilds
  data_request(SWGOH::API::COLLECTION::STARTER_GUILD)
end

#stat_mod_setsJSON || nil

Returns:

  • (JSON || nil)


193
194
195
# File 'lib/SWGOH/API/CLIENT/client.rb', line 193

def stat_mod_sets
  data_request(SWGOH::API::COLLECTION::STAT_MOD_SET)
end

#stat_modsJSON || nil

Returns:

  • (JSON || nil)


188
189
190
# File 'lib/SWGOH/API/CLIENT/client.rb', line 188

def stat_mods
  data_request(SWGOH::API::COLLECTION::STAT_MOD)
end

#stat_progressionsJSON || nil

Returns:

  • (JSON || nil)


198
199
200
# File 'lib/SWGOH/API/CLIENT/client.rb', line 198

def stat_progressions
  data_request(SWGOH::API::COLLECTION::STAT_PROGRESSION)
end

#tablesJSON || nil

Returns:

  • (JSON || nil)


203
204
205
# File 'lib/SWGOH/API/CLIENT/client.rb', line 203

def tables
  data_request(SWGOH::API::COLLECTION::TABLE)
end

#targeting_setsJSON || nil

Returns:

  • (JSON || nil)


208
209
210
# File 'lib/SWGOH/API/CLIENT/client.rb', line 208

def targeting_sets
  data_request(SWGOH::API::COLLECTION::TARGETING_SET)
end

#territory_battle_definitionsJSON || nil

Returns:

  • (JSON || nil)


213
214
215
# File 'lib/SWGOH/API/CLIENT/client.rb', line 213

def territory_battle_definitions
  data_request(SWGOH::API::COLLECTION::TERRITORY_BATTLE_DEFINITION)
end

#territory_war_definitionsJSON || nil

Returns:

  • (JSON || nil)


218
219
220
# File 'lib/SWGOH/API/CLIENT/client.rb', line 218

def territory_war_definitions
  data_request(SWGOH::API::COLLECTION::TERRITORY_WAR_DEFINITION)
end

#units(ally_codes) ⇒ JSON || nil

Parameters:

  • ally_codes (Array)

Returns:

  • (JSON || nil)


58
59
60
# File 'lib/SWGOH/API/CLIENT/client.rb', line 58

def units(ally_codes)
  ally_codes_request(SWGOH::API::PATH::UNITS, ally_codes)
end

#units_listJSON || nil

Returns:

  • (JSON || nil)


223
224
225
# File 'lib/SWGOH/API/CLIENT/client.rb', line 223

def units_list
  data_request(SWGOH::API::COLLECTION::UNIT)
end

#unlock_announcement_defsJSON || nil

Returns:

  • (JSON || nil)


228
229
230
# File 'lib/SWGOH/API/CLIENT/client.rb', line 228

def unlock_announcement_defs
  data_request(SWGOH::API::COLLECTION::UNLOCK_ANNOUNCEMENT_DEFINITION)
end

#war_definitionsJSON || nil

Returns:

  • (JSON || nil)


233
234
235
# File 'lib/SWGOH/API/CLIENT/client.rb', line 233

def war_definitions
  data_request(SWGOH::API::COLLECTION::WAR_DEFINITION)
end

#xp_tablesJSON || nil

Returns:

  • (JSON || nil)


238
239
240
# File 'lib/SWGOH/API/CLIENT/client.rb', line 238

def xp_tables
  data_request(SWGOH::API::COLLECTION::XP_TABLE)
end

#zetasJSON || nil

Returns:

  • (JSON || nil)


63
64
65
# File 'lib/SWGOH/API/CLIENT/client.rb', line 63

def zetas
  request(SWGOH::API::PATH::ZETAS)
end