Class: Amiando::PaymentType
- Defined in:
- lib/amiando/payment_type.rb
Instance Attribute Summary
Attributes inherited from Resource
Class Method Summary collapse
-
.create(event_id, type) ⇒ Object
Create a payment type for an event.
-
.find(payment_type_id) ⇒ PaymentType
Find a Payment Type.
-
.find_all_by_event_id(event_id) ⇒ Result
Find all Payment Types of an event.
-
.update(payment_type_id, attributes) ⇒ Boolean
Update a payment type.
Methods inherited from Resource
#==, #extract_attributes_from, #initialize, method_missing, #populate_create
Methods included from Attributes
#[], #id, included, #method_missing, #respond_to?, #type
Methods included from Autorun
Constructor Details
This class inherits a constructor from Amiando::Resource
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Amiando::Attributes
Class Method Details
.create(event_id, type) ⇒ Object
Create a payment type for an event
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/amiando/payment_type.rb', line 18 def self.create(event_id, type) type = type[:type] if type.is_a?(Hash) unless type =~ /^payment_type_\w+/i type = "payment_type_#{type}" end object = Result.new do |response_body, result| result.errors = response_body['errors'] response_body['id'] || false end post object, "api/event/#{event_id}/paymentType/create", :params => { :type => type.upcase } object end |
.find(payment_type_id) ⇒ PaymentType
Find a Payment Type
64 65 66 67 68 69 |
# File 'lib/amiando/payment_type.rb', line 64 def self.find(payment_type_id) object = new get object, "api/paymentType/#{payment_type_id}" object end |
.find_all_by_event_id(event_id) ⇒ Result
Find all Payment Types of an event
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/amiando/payment_type.rb', line 41 def self.find_all_by_event_id(event_id) object = Result.new do |response_body, result| if response_body['success'] response_body['results']['paymentTypes'].map do |payment_type| new(payment_type) end else result.errors = response_body['errors'] false end end get object, "api/event/#{event_id}/paymentTypes" object end |