Class: PuntosPoint::Api
- Inherits:
-
Object
- Object
- PuntosPoint::Api
- Defined in:
- lib/puntospoint/api.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
- #confirm_purchase(purchase_id) ⇒ Object
- #create_purchase(rut, email, exchange_id, references_codes = nil) ⇒ Object
- #get_event(event_id) ⇒ Object
- #get_events ⇒ Object
-
#initialize(env = nil) ⇒ Api
constructor
A new instance of Api.
- #redeem_purchase(purchase_id) ⇒ Object
Constructor Details
#initialize(env = nil) ⇒ Api
Returns a new instance of Api.
5 6 7 8 9 10 |
# File 'lib/puntospoint/api.rb', line 5 def initialize(env = nil) @env = env @@config ||= PuntosPoint::Config.new(@env) @@wsdl_url ||= @@config.wsdl_url @client = ::Savon.client(wsdl: @@wsdl_url, headers: { 'Authentication' => @@config.api_password }) end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
3 4 5 |
# File 'lib/puntospoint/api.rb', line 3 def client @client end |
Instance Method Details
#confirm_purchase(purchase_id) ⇒ Object
33 34 35 36 |
# File 'lib/puntospoint/api.rb', line 33 def confirm_purchase(purchase_id) @client.call(:confirm_purchase, message: { purchase_id: purchase_id }) .body[:confirm_purchase_response][:value] rescue nil end |
#create_purchase(rut, email, exchange_id, references_codes = nil) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/puntospoint/api.rb', line 22 def create_purchase(rut, email, exchange_id, references_codes = nil) @client.call(:create_purchase, message: { rut: rut, email: email, exchange_id: exchange_id, reference_codes: references_codes }) .body[:create_purchase_response][:value] rescue nil end |
#get_event(event_id) ⇒ Object
17 18 19 20 |
# File 'lib/puntospoint/api.rb', line 17 def get_event(event_id) @client.call(:get_event, message: { event_id: event_id }) .body[:get_event_response][:value] rescue nil end |
#get_events ⇒ Object
12 13 14 15 |
# File 'lib/puntospoint/api.rb', line 12 def get_events @client.call(:get_events) .body[:get_events_response][:value] rescue nil end |
#redeem_purchase(purchase_id) ⇒ Object
38 39 40 41 |
# File 'lib/puntospoint/api.rb', line 38 def redeem_purchase(purchase_id) @client.call(:redeem_purchase, message: { purchase_id: purchase_id }) .body[:redeem_purchase_response][:value] rescue nil end |