Class: Tangocard::Raas
- Inherits:
-
Object
- Object
- Tangocard::Raas
- Includes:
- HTTParty
- Defined in:
- lib/tangocard/raas.rb
Class Method Summary collapse
-
.cc_fund_account(params) ⇒ Object
Funds an account.
-
.create_account(params) ⇒ Object
Create a new account.
-
.create_order(params) ⇒ Object
Create an order.
-
.delete_credit_card(params) ⇒ Object
Deletes a credit card from an account.
-
.orders_index(params = {}) ⇒ Object
Retrieve a list of historical orders.
-
.register_credit_card(params) ⇒ Object
Registers a credit card to an account.
-
.rewards_index(use_cache: true) ⇒ Object
Retrieve all rewards.
-
.show_account(params) ⇒ Object
Gets account details.
-
.show_order(params) ⇒ Object
Get order details.
Class Method Details
.cc_fund_account(params) ⇒ Object
Funds an account. Returns Tangocard::Response object.
Example:
>> Tangocard::Raas.cc_fund_account(params)
=> #<Tangocard::Response:0x007f9a6c4bca68 ...>
Arguments:
params: (Hash - see https://www.tangocard.com/docs/raas-api/#create-cc-fund for details)
36 37 38 |
# File 'lib/tangocard/raas.rb', line 36 def self.cc_fund_account(params) Tangocard::Response.new(post_request('/cc_fund', { body: params.to_json })) end |
.create_account(params) ⇒ Object
Create a new account. Returns Tangocard::Response object.
Example:
>> Tangocard::Raas.create_account(params)
=> #<Tangocard::Response:0x007f9a6c4bca68 ...>
Arguments:
params: (Hash - see https://www.tangocard.com/docs/raas-api/#create-account for details)
12 13 14 |
# File 'lib/tangocard/raas.rb', line 12 def self.create_account(params) Tangocard::Response.new(post_request('/accounts', { body: params.to_json })) end |
.create_order(params) ⇒ Object
Create an order. Returns Tangocard::Response object.
Example:
>> Tangocard::Raas.create_order(params)
=> #<Tangocard::Response:0x007f9a6c4bca68 ...>
Arguments:
params: (Hash - see https://www.tangocard.com/docs/raas-api/#create-order for details)
90 91 92 |
# File 'lib/tangocard/raas.rb', line 90 def self.create_order(params) Tangocard::Response.new(post_request('/orders', { body: params.to_json })) end |
.delete_credit_card(params) ⇒ Object
Deletes a credit card from an account. Returns Tangocard::Response object.
Example:
>> Tangocard::Raas.delete_credit_card(params)
=> #<Tangocard::Response:0x007f9a6c4bca68 ...>
Arguments:
params: (Hash - see https://www.tangocard.com/docs/raas-api/#create-cc-un-registration for details)
60 61 62 |
# File 'lib/tangocard/raas.rb', line 60 def self.delete_credit_card(params) Tangocard::Response.new(post_request('/cc_unregister', { body: params.to_json })) end |
.orders_index(params = {}) ⇒ Object
Retrieve a list of historical orders. Returns Tangocard::Response object.
Example:
>> Tangocard::Raas.orders_index
=> #<Tangocard::Response:0x007f9a6c4bca68 ...>
Arguments:
params: (Hash - see https://www.tangocard.com/docs/raas-api/#list-orders for details)
114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/tangocard/raas.rb', line 114 def self.orders_index(params = {}) query_string = "" if params.any? query_string = "?" params.keys.each_with_index do |k, i| query_string += "&" unless i == 0 query_string += "#{k}=#{params[k]}" end end Tangocard::Response.new(get_request("/orders#{query_string}")) end |
.register_credit_card(params) ⇒ Object
Registers a credit card to an account. Returns Tangocard::Response object.
Example:
>> Tangocard::Raas.register_credit_card(params)
=> #<Tangocard::Response:0x007f9a6c4bca68 ...>
Arguments:
params: (Hash - see https://www.tangocard.com/docs/raas-api/#create-cc-registration for details)
48 49 50 |
# File 'lib/tangocard/raas.rb', line 48 def self.register_credit_card(params) Tangocard::Response.new(post_request('/cc_register', { body: params.to_json })) end |
.rewards_index(use_cache: true) ⇒ Object
Retrieve all rewards. Returns Tangocard::Response object.
Example:
>> Tangocard::Raas.rewards_index
=> #<Tangocard::Response:0x007f9a6c4bca68 ...>
Arguments:
none
72 73 74 75 76 77 78 79 80 |
# File 'lib/tangocard/raas.rb', line 72 def self.rewards_index(use_cache: true) if Tangocard.configuration.use_cache && use_cache cached_response = Tangocard.configuration.cache.read("#{Tangocard::CACHE_PREFIX}rewards_index") raise Tangocard::RaasException.new('Tangocard cache is not primed. Either configure the gem to run without caching or warm the cache before calling cached endpoints') if cached_response.nil? cached_response else Tangocard::Response.new(get_request('/rewards')) end end |
.show_account(params) ⇒ Object
Gets account details. Returns Tangocard::Response object.
Example:
>> Tangocard::Raas.show_account(params)
=> #<Tangocard::Response:0x007f9a6c4bca68 ...>
Arguments:
params: (Hash - see https://www.tangocard.com/docs/raas-api/#get-account for details)
24 25 26 |
# File 'lib/tangocard/raas.rb', line 24 def self.show_account(params) Tangocard::Response.new(get_request("/accounts/#{params['customer']}/#{params['identifier']}")) end |
.show_order(params) ⇒ Object
Get order details. Returns Tangocard::Response object.
Example:
>> Tangocard::Raas.show_order(params)
=> #<Tangocard::Response:0x007f9a6c4bca68 ...>
Arguments:
params: (Hash - see https://www.tangocard.com/docs/raas-api/#get-order for details)
102 103 104 |
# File 'lib/tangocard/raas.rb', line 102 def self.show_order(params) Tangocard::Response.new(get_request("/orders/#{params['order_id']}")) end |