Class: Gyftwrapper::API
- Inherits:
-
Object
- Object
- Gyftwrapper::API
- Includes:
- Resultable
- Defined in:
- lib/gyftwrapper/api.rb
Constant Summary collapse
- CALLS =
{ purchase_card: '/reseller/purchase/card', get_merchants: '/reseller/merchants' }
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#result ⇒ Object
Returns the value of attribute result.
Instance Method Summary collapse
- #get_merchants ⇒ Object
-
#initialize ⇒ API
constructor
A new instance of API.
- #purchase_card(params) ⇒ Object
Constructor Details
#initialize ⇒ API
Returns a new instance of API.
20 21 22 23 |
# File 'lib/gyftwrapper/api.rb', line 20 def initialize self.result = Result.new self.config = parse_config_file end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
18 19 20 |
# File 'lib/gyftwrapper/api.rb', line 18 def config @config end |
#result ⇒ Object
Returns the value of attribute result.
18 19 20 |
# File 'lib/gyftwrapper/api.rb', line 18 def result @result end |
Instance Method Details
#get_merchants ⇒ Object
33 34 35 36 37 38 |
# File 'lib/gyftwrapper/api.rb', line 33 def get_merchants send_request do response = RestClient.get(url_for(:get_merchants), 'x-sig-timestamp' => ) self.result = JSON.parse(response)['details'].map{|m| OpenStruct.new(m)} end end |
#purchase_card(params) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/gyftwrapper/api.rb', line 25 def purchase_card(params) send_request do response = RestClient.post(url_for(:purchase_card), params.merge(default_params), 'x-sig-timestamp' => ) self.result.response = OpenStruct.new(JSON.parse(response)) self.result.successful! end end |