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



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/processout/invoice_shipping.rb', line 100

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)
  
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

#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

#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



148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
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
# File 'lib/processout/invoice_shipping.rb', line 148

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
  
  self
end

#new(data = {}) ⇒ Object

Create a new InvoiceShipping using the current client



121
122
123
# File 'lib/processout/invoice_shipping.rb', line 121

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



201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
# File 'lib/processout/invoice_shipping.rb', line 201

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
end

#to_json(options) ⇒ Object

Overrides the JSON marshaller to only send the fields we want



126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/processout/invoice_shipping.rb', line 126

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,
  }.to_json
end