Class: ProcessOut::Submerchant
- Inherits:
-
Object
- Object
- ProcessOut::Submerchant
- Defined in:
- lib/processout/submerchant.rb
Instance Attribute Summary collapse
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
-
#fill_with_data(data) ⇒ Object
Fills the object with data coming from the API Params:
data::Hashof data coming from the API. -
#initialize(client, data = {}) ⇒ Submerchant
constructor
Initializes the Submerchant object Params:
client::ProcessOutclient instancedata:: data that can be used to fill the object. -
#new(data = {}) ⇒ Object
Create a new Submerchant using the current client.
-
#prefill(data) ⇒ Object
Prefills the object with the data passed as parameters Params:
data::Hashof data. -
#to_json(options) ⇒ Object
Overrides the JSON marshaller to only send the fields we want.
Constructor Details
#initialize(client, data = {}) ⇒ Submerchant
Initializes the Submerchant object Params:
clientProcessOutclient instancedatadata that can be used to fill the object
33 34 35 36 37 38 39 40 |
# File 'lib/processout/submerchant.rb', line 33 def initialize(client, data = {}) @client = client self.id = data.fetch(:id, nil) self.name = data.fetch(:name, nil) self.created_at = data.fetch(:created_at, nil) end |
Instance Attribute Details
#created_at ⇒ Object
Returns the value of attribute created_at.
13 14 15 |
# File 'lib/processout/submerchant.rb', line 13 def created_at @created_at end |
#id ⇒ Object
Returns the value of attribute id.
11 12 13 |
# File 'lib/processout/submerchant.rb', line 11 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
12 13 14 |
# File 'lib/processout/submerchant.rb', line 12 def name @name end |
Instance Method Details
#fill_with_data(data) ⇒ Object
Fills the object with data coming from the API Params:
dataHashof data coming from the API
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/processout/submerchant.rb', line 59 def fill_with_data(data) if data.nil? return self end if data.include? "id" self.id = data["id"] end if data.include? "name" self.name = data["name"] end if data.include? "created_at" self.created_at = data["created_at"] end self end |
#new(data = {}) ⇒ Object
Create a new Submerchant using the current client
43 44 45 |
# File 'lib/processout/submerchant.rb', line 43 def new(data = {}) Submerchant.new(@client, data) end |
#prefill(data) ⇒ Object
Prefills the object with the data passed as parameters Params:
dataHashof data
79 80 81 82 83 84 85 86 87 88 |
# File 'lib/processout/submerchant.rb', line 79 def prefill(data) if data.nil? return self end self.id = data.fetch(:id, self.id) self.name = data.fetch(:name, self.name) self.created_at = data.fetch(:created_at, self.created_at) self end |
#to_json(options) ⇒ Object
Overrides the JSON marshaller to only send the fields we want
48 49 50 51 52 53 54 |
# File 'lib/processout/submerchant.rb', line 48 def to_json() { "id": self.id, "name": self.name, "created_at": self.created_at, }.to_json end |