Class: ProcessOut::InvoiceSubmerchant

Inherits:
Object
  • Object
show all
Defined in:
lib/processout/invoice_submerchant.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, data = {}) ⇒ InvoiceSubmerchant

Initializes the InvoiceSubmerchant object Params:

client

ProcessOut client instance

data

data that can be used to fill the object



87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/processout/invoice_submerchant.rb', line 87

def initialize(client, data = {})
  @client = client

  self.id = data.fetch(:id, nil)
  self.name = data.fetch(:name, nil)
  self.reference = data.fetch(:reference, nil)
  self.mcc = data.fetch(:mcc, nil)
  self.phone_number = data.fetch(:phone_number, nil)
  self.email = data.fetch(:email, nil)
  self.address = data.fetch(:address, nil)
  self.tax_reference = data.fetch(:tax_reference, nil)
  self.service_establishment_number = data.fetch(:service_establishment_number, nil)
  
end

Instance Attribute Details

#addressObject

Returns the value of attribute address.



17
18
19
# File 'lib/processout/invoice_submerchant.rb', line 17

def address
  @address
end

#emailObject

Returns the value of attribute email.



16
17
18
# File 'lib/processout/invoice_submerchant.rb', line 16

def email
  @email
end

#idObject

Returns the value of attribute id.



11
12
13
# File 'lib/processout/invoice_submerchant.rb', line 11

def id
  @id
end

#mccObject

Returns the value of attribute mcc.



14
15
16
# File 'lib/processout/invoice_submerchant.rb', line 14

def mcc
  @mcc
end

#nameObject

Returns the value of attribute name.



12
13
14
# File 'lib/processout/invoice_submerchant.rb', line 12

def name
  @name
end

#phone_numberObject

Returns the value of attribute phone_number.



15
16
17
# File 'lib/processout/invoice_submerchant.rb', line 15

def phone_number
  @phone_number
end

#referenceObject

Returns the value of attribute reference.



13
14
15
# File 'lib/processout/invoice_submerchant.rb', line 13

def reference
  @reference
end

#service_establishment_numberObject

Returns the value of attribute service_establishment_number.



19
20
21
# File 'lib/processout/invoice_submerchant.rb', line 19

def service_establishment_number
  @service_establishment_number
end

#tax_referenceObject

Returns the value of attribute tax_reference.



18
19
20
# File 'lib/processout/invoice_submerchant.rb', line 18

def tax_reference
  @tax_reference
end

Instance Method Details

#fill_with_data(data) ⇒ Object

Fills the object with data coming from the API Params:

data

Hash of data coming from the API



125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/processout/invoice_submerchant.rb', line 125

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? "reference"
    self.reference = data["reference"]
  end
  if data.include? "mcc"
    self.mcc = data["mcc"]
  end
  if data.include? "phone_number"
    self.phone_number = data["phone_number"]
  end
  if data.include? "email"
    self.email = data["email"]
  end
  if data.include? "address"
    self.address = data["address"]
  end
  if data.include? "tax_reference"
    self.tax_reference = data["tax_reference"]
  end
  if data.include? "service_establishment_number"
    self.service_establishment_number = data["service_establishment_number"]
  end
  
  self
end

#new(data = {}) ⇒ Object

Create a new InvoiceSubmerchant using the current client



103
104
105
# File 'lib/processout/invoice_submerchant.rb', line 103

def new(data = {})
  InvoiceSubmerchant.new(@client, data)
end

#prefill(data) ⇒ Object

Prefills the object with the data passed as parameters Params:

data

Hash of data



163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
# File 'lib/processout/invoice_submerchant.rb', line 163

def prefill(data)
  if data.nil?
    return self
  end
  self.id = data.fetch(:id, self.id)
  self.name = data.fetch(:name, self.name)
  self.reference = data.fetch(:reference, self.reference)
  self.mcc = data.fetch(:mcc, self.mcc)
  self.phone_number = data.fetch(:phone_number, self.phone_number)
  self.email = data.fetch(:email, self.email)
  self.address = data.fetch(:address, self.address)
  self.tax_reference = data.fetch(:tax_reference, self.tax_reference)
  self.service_establishment_number = data.fetch(:service_establishment_number, self.service_establishment_number)
  
  self
end

#to_json(options) ⇒ Object

Overrides the JSON marshaller to only send the fields we want



108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/processout/invoice_submerchant.rb', line 108

def to_json(options)
  {
      "id": self.id,
      "name": self.name,
      "reference": self.reference,
      "mcc": self.mcc,
      "phone_number": self.phone_number,
      "email": self.email,
      "address": self.address,
      "tax_reference": self.tax_reference,
      "service_establishment_number": self.service_establishment_number,
  }.to_json
end