Class: CLIENT
- Inherits:
-
Object
- Object
- CLIENT
- Defined in:
- lib/SWGOH/API/CLIENT/client.rb
Overview
The CLIENT class makes requests to api.swgoh.api
Instance Attribute Summary collapse
-
#access_token ⇒ Object
writeonly
Sets the attribute access_token.
-
#enums ⇒ Object
Returns the value of attribute enums.
-
#language ⇒ Object
Returns the value of attribute language.
-
#project ⇒ Object
Returns the value of attribute project.
-
#structure ⇒ Object
Returns the value of attribute structure.
Instance Method Summary collapse
- #abilities ⇒ JSON || nil
- #authorize(username, password) ⇒ String | nil
- #authorized? ⇒ Boolean
- #battle_environments ⇒ JSON || nil
- #battle_targeting_rules ⇒ JSON || nil
- #battles ⇒ JSON || nil
- #categories ⇒ JSON || nil
- #challenge_styles ⇒ JSON || nil
- #challenges ⇒ JSON || nil
- #effects ⇒ JSON || nil
- #environment_collections ⇒ JSON || nil
- #equipment ⇒ JSON || nil
- #event_samples ⇒ JSON || nil
- #events ⇒ JSON || nil
- #guild_exchange_items ⇒ JSON || nil
- #guild_raids ⇒ JSON || nil
- #guilds(ally_codes) ⇒ JSON || nil
- #help_entries ⇒ JSON || nil
-
#initialize ⇒ CLIENT
constructor
A new instance of CLIENT.
- #materials ⇒ JSON || nil
- #player_titles ⇒ JSON || nil
- #players(ally_codes) ⇒ JSON || nil
- #power_up_bundles ⇒ JSON || nil
- #raid_configs ⇒ JSON || nil
- #recipes ⇒ JSON || nil
- #requirements ⇒ JSON || nil
- #rosters(ally_codes) ⇒ JSON || nil
- #skills ⇒ JSON || nil
- #squads ⇒ JSON || nil
- #starter_guilds ⇒ JSON || nil
- #stat_mod_sets ⇒ JSON || nil
- #stat_mods ⇒ JSON || nil
- #stat_progressions ⇒ JSON || nil
- #tables ⇒ JSON || nil
- #targeting_sets ⇒ JSON || nil
- #territory_battle_definitions ⇒ JSON || nil
- #territory_war_definitions ⇒ JSON || nil
- #units(ally_codes) ⇒ JSON || nil
- #units_list ⇒ JSON || nil
- #unlock_announcement_defs ⇒ JSON || nil
- #war_definitions ⇒ JSON || nil
- #xp_tables ⇒ JSON || nil
- #zetas ⇒ JSON || nil
Constructor Details
#initialize ⇒ CLIENT
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
11 12 13 |
# File 'lib/SWGOH/API/CLIENT/client.rb', line 11 def access_token=(value) @access_token = value end |
#enums ⇒ Object
Returns the value of attribute enums.
10 11 12 |
# File 'lib/SWGOH/API/CLIENT/client.rb', line 10 def enums @enums end |
#language ⇒ Object
Returns the value of attribute language.
10 11 12 |
# File 'lib/SWGOH/API/CLIENT/client.rb', line 10 def language @language end |
#project ⇒ Object
Returns the value of attribute project.
10 11 12 |
# File 'lib/SWGOH/API/CLIENT/client.rb', line 10 def project @project end |
#structure ⇒ Object
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
#abilities ⇒ 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
29 30 31 32 33 34 35 36 |
# File 'lib/SWGOH/API/CLIENT/client.rb', line 29 def (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
22 23 24 |
# File 'lib/SWGOH/API/CLIENT/client.rb', line 22 def !@access_token.nil? end |
#battle_environments ⇒ 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_rules ⇒ 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 |
#battles ⇒ JSON || nil
78 79 80 |
# File 'lib/SWGOH/API/CLIENT/client.rb', line 78 def battles request(SWGOH::API::PATH::BATTLES) end |
#categories ⇒ JSON || nil
98 99 100 |
# File 'lib/SWGOH/API/CLIENT/client.rb', line 98 def categories data_request(SWGOH::API::COLLECTION::CATEGORY) end |
#challenge_styles ⇒ 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 |
#challenges ⇒ JSON || nil
103 104 105 |
# File 'lib/SWGOH/API/CLIENT/client.rb', line 103 def challenges data_request(SWGOH::API::COLLECTION::CHALLENGE) end |
#effects ⇒ JSON || nil
113 114 115 |
# File 'lib/SWGOH/API/CLIENT/client.rb', line 113 def effects data_request(SWGOH::API::COLLECTION::EFFECT) end |
#environment_collections ⇒ 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 |
#equipment ⇒ JSON || nil
123 124 125 |
# File 'lib/SWGOH/API/CLIENT/client.rb', line 123 def equipment data_request(SWGOH::API::COLLECTION::EQUIPMENT) end |
#event_samples ⇒ 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 |
#events ⇒ JSON || nil
73 74 75 |
# File 'lib/SWGOH/API/CLIENT/client.rb', line 73 def events request(SWGOH::API::PATH::EVENTS) end |
#guild_exchange_items ⇒ 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_raids ⇒ 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
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_entries ⇒ 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 |
#materials ⇒ JSON || nil
148 149 150 |
# File 'lib/SWGOH/API/CLIENT/client.rb', line 148 def materials data_request(SWGOH::API::COLLECTION::MATERIAL) end |
#player_titles ⇒ 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
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_bundles ⇒ 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_configs ⇒ 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 |
#recipes ⇒ JSON || nil
168 169 170 |
# File 'lib/SWGOH/API/CLIENT/client.rb', line 168 def recipes data_request(SWGOH::API::COLLECTION::RECIPE) end |
#requirements ⇒ 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
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 |
#skills ⇒ JSON || nil
178 179 180 |
# File 'lib/SWGOH/API/CLIENT/client.rb', line 178 def skills data_request(SWGOH::API::COLLECTION::SKILL) end |
#squads ⇒ JSON || nil
68 69 70 |
# File 'lib/SWGOH/API/CLIENT/client.rb', line 68 def squads request(SWGOH::API::PATH::SQUADS) end |
#starter_guilds ⇒ 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_sets ⇒ 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_mods ⇒ 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_progressions ⇒ 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 |
#tables ⇒ JSON || nil
203 204 205 |
# File 'lib/SWGOH/API/CLIENT/client.rb', line 203 def tables data_request(SWGOH::API::COLLECTION::TABLE) end |
#targeting_sets ⇒ 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_definitions ⇒ 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_definitions ⇒ 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
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_list ⇒ 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_defs ⇒ 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_definitions ⇒ 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_tables ⇒ 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 |
#zetas ⇒ JSON || nil
63 64 65 |
# File 'lib/SWGOH/API/CLIENT/client.rb', line 63 def zetas request(SWGOH::API::PATH::ZETAS) end |