Class: HearthstoneCardApi::Caller

Inherits:
Object
  • Object
show all
Defined in:
lib/hearthstone_card_api/caller.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Caller

Returns a new instance of Caller.



6
7
8
9
10
11
12
# File 'lib/hearthstone_card_api/caller.rb', line 6

def initialize(args={})
  @api_key = HearthstoneCardApi.api_key 
  @api_url = "https://omgvamp-hearthstone-v1.p.mashape.com/"

  @collectible = "1"
  @filters = {cost: nil, attack: nil, health: nil, durability: nil}
end

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



4
5
6
# File 'lib/hearthstone_card_api/caller.rb', line 4

def api_key
  @api_key
end

#api_urlObject

Returns the value of attribute api_url.



4
5
6
# File 'lib/hearthstone_card_api/caller.rb', line 4

def api_url
  @api_url
end

#collectibleObject

Returns the value of attribute collectible.



4
5
6
# File 'lib/hearthstone_card_api/caller.rb', line 4

def collectible
  @collectible
end

#filtersObject

Returns the value of attribute filters.



4
5
6
# File 'lib/hearthstone_card_api/caller.rb', line 4

def filters
  @filters
end

Instance Method Details

#return_cards(args = {}) ⇒ Object



14
15
16
17
# File 'lib/hearthstone_card_api/caller.rb', line 14

def return_cards(args={}) 
  url = add_filters_to_url(args)
  api_response(endpoint(url))
end

#return_info(url) ⇒ Object



19
20
21
# File 'lib/hearthstone_card_api/caller.rb', line 19

def return_info(url)
  api_response(endpoint(url))
end