Class: ProcessOut::InvoiceShipping

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Initializes the InvoiceShipping object Params:

client

ProcessOut client instance

data

data that can be used to fill the object



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/processout/invoice_shipping.rb', line 115

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

  self.amount = data.fetch(:amount, nil)
  self.method = data.fetch(:method, nil)
  self.provider = data.fetch(:provider, nil)
  self.delay = data.fetch(:delay, nil)
  self.address1 = data.fetch(:address1, nil)
  self.address2 = data.fetch(:address2, nil)
  self.city = data.fetch(:city, nil)
  self.state = data.fetch(:state, nil)
  self.country_code = data.fetch(:country_code, nil)
  self.zip = data.fetch(:zip, nil)
  self.phone_number = data.fetch(:phone_number, nil)
  self.phone = data.fetch(:phone, nil)
  self.expects_shipping_at = data.fetch(:expects_shipping_at, nil)
  self.relay_store_name = data.fetch(:relay_store_name, nil)
  self.first_name = data.fetch(:first_name, nil)
  self.last_name = data.fetch(:last_name, nil)
  self.email = data.fetch(:email, nil)
  
end

Instance Attribute Details

#address1Object

Returns the value of attribute address1.



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

def address1
  @address1
end

#address2Object

Returns the value of attribute address2.



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

def address2
  @address2
end

#amountObject

Returns the value of attribute amount.



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

def amount
  @amount
end

#cityObject

Returns the value of attribute city.



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

def city
  @city
end

#country_codeObject

Returns the value of attribute country_code.



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

def country_code
  @country_code
end

#delayObject

Returns the value of attribute delay.



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

def delay
  @delay
end

#emailObject

Returns the value of attribute email.



27
28
29
# File 'lib/processout/invoice_shipping.rb', line 27

def email
  @email
end

#expects_shipping_atObject

Returns the value of attribute expects_shipping_at.



23
24
25
# File 'lib/processout/invoice_shipping.rb', line 23

def expects_shipping_at
  @expects_shipping_at
end

#first_nameObject

Returns the value of attribute first_name.



25
26
27
# File 'lib/processout/invoice_shipping.rb', line 25

def first_name
  @first_name
end

#last_nameObject

Returns the value of attribute last_name.



26
27
28
# File 'lib/processout/invoice_shipping.rb', line 26

def last_name
  @last_name
end

#methodObject

Returns the value of attribute method.



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

def method
  @method
end

#phoneObject

Returns the value of attribute phone.



22
23
24
# File 'lib/processout/invoice_shipping.rb', line 22

def phone
  @phone
end

#phone_numberObject

Returns the value of attribute phone_number.



21
22
23
# File 'lib/processout/invoice_shipping.rb', line 21

def phone_number
  @phone_number
end

#providerObject

Returns the value of attribute provider.



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

def provider
  @provider
end

#relay_store_nameObject

Returns the value of attribute relay_store_name.



24
25
26
# File 'lib/processout/invoice_shipping.rb', line 24

def relay_store_name
  @relay_store_name
end

#stateObject

Returns the value of attribute state.



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

def state
  @state
end

#zipObject

Returns the value of attribute zip.



20
21
22
# File 'lib/processout/invoice_shipping.rb', line 20

def zip
  @zip
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



169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# File 'lib/processout/invoice_shipping.rb', line 169

def fill_with_data(data)
  if data.nil?
    return self
  end
  if data.include? "amount"
    self.amount = data["amount"]
  end
  if data.include? "method"
    self.method = data["method"]
  end
  if data.include? "provider"
    self.provider = data["provider"]
  end
  if data.include? "delay"
    self.delay = data["delay"]
  end
  if data.include? "address1"
    self.address1 = data["address1"]
  end
  if data.include? "address2"
    self.address2 = data["address2"]
  end
  if data.include? "city"
    self.city = data["city"]
  end
  if data.include? "state"
    self.state = data["state"]
  end
  if data.include? "country_code"
    self.country_code = data["country_code"]
  end
  if data.include? "zip"
    self.zip = data["zip"]
  end
  if data.include? "phone_number"
    self.phone_number = data["phone_number"]
  end
  if data.include? "phone"
    self.phone = data["phone"]
  end
  if data.include? "expects_shipping_at"
    self.expects_shipping_at = data["expects_shipping_at"]
  end
  if data.include? "relay_store_name"
    self.relay_store_name = data["relay_store_name"]
  end
  if data.include? "first_name"
    self.first_name = data["first_name"]
  end
  if data.include? "last_name"
    self.last_name = data["last_name"]
  end
  if data.include? "email"
    self.email = data["email"]
  end
  
  self
end

#new(data = {}) ⇒ Object

Create a new InvoiceShipping using the current client



139
140
141
# File 'lib/processout/invoice_shipping.rb', line 139

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

#prefill(data) ⇒ Object

Prefills the object with the data passed as parameters Params:

data

Hash of data



231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
# File 'lib/processout/invoice_shipping.rb', line 231

def prefill(data)
  if data.nil?
    return self
  end
  self.amount = data.fetch(:amount, self.amount)
  self.method = data.fetch(:method, self.method)
  self.provider = data.fetch(:provider, self.provider)
  self.delay = data.fetch(:delay, self.delay)
  self.address1 = data.fetch(:address1, self.address1)
  self.address2 = data.fetch(:address2, self.address2)
  self.city = data.fetch(:city, self.city)
  self.state = data.fetch(:state, self.state)
  self.country_code = data.fetch(:country_code, self.country_code)
  self.zip = data.fetch(:zip, self.zip)
  self.phone_number = data.fetch(:phone_number, self.phone_number)
  self.phone = data.fetch(:phone, self.phone)
  self.expects_shipping_at = data.fetch(:expects_shipping_at, self.expects_shipping_at)
  self.relay_store_name = data.fetch(:relay_store_name, self.relay_store_name)
  self.first_name = data.fetch(:first_name, self.first_name)
  self.last_name = data.fetch(:last_name, self.last_name)
  self.email = data.fetch(:email, self.email)
  
  self
end

#to_json(options) ⇒ Object

Overrides the JSON marshaller to only send the fields we want



144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/processout/invoice_shipping.rb', line 144

def to_json(options)
  {
      "amount": self.amount,
      "method": self.method,
      "provider": self.provider,
      "delay": self.delay,
      "address1": self.address1,
      "address2": self.address2,
      "city": self.city,
      "state": self.state,
      "country_code": self.country_code,
      "zip": self.zip,
      "phone_number": self.phone_number,
      "phone": self.phone,
      "expects_shipping_at": self.expects_shipping_at,
      "relay_store_name": self.relay_store_name,
      "first_name": self.first_name,
      "last_name": self.last_name,
      "email": self.email,
  }.to_json
end