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



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/processout/invoice_shipping.rb', line 77

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.expects_shipping_at = data.fetch(:expects_shipping_at, nil)
  
end

Instance Attribute Details

#address1Object

Returns the value of attribute address1.



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

def address1
  @address1
end

#address2Object

Returns the value of attribute address2.



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

def address2
  @address2
end

#amountObject

Returns the value of attribute amount.



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

def amount
  @amount
end

#cityObject

Returns the value of attribute city.



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

def city
  @city
end

#country_codeObject

Returns the value of attribute country_code.



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

def country_code
  @country_code
end

#delayObject

Returns the value of attribute delay.



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

def delay
  @delay
end

#expects_shipping_atObject

Returns the value of attribute expects_shipping_at.



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

def expects_shipping_at
  @expects_shipping_at
end

#methodObject

Returns the value of attribute method.



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

def method
  @method
end

#phone_numberObject

Returns the value of attribute phone_number.



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

def phone_number
  @phone_number
end

#providerObject

Returns the value of attribute provider.



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

def provider
  @provider
end

#stateObject

Returns the value of attribute state.



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

def state
  @state
end

#zipObject

Returns the value of attribute zip.



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

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



103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/processout/invoice_shipping.rb', line 103

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? "expects_shipping_at"
    self.expects_shipping_at = data["expects_shipping_at"]
  end
  
  self
end

#new(data = {}) ⇒ Object

Create a new InvoiceShipping using the current client



96
97
98
# File 'lib/processout/invoice_shipping.rb', line 96

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



150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# File 'lib/processout/invoice_shipping.rb', line 150

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.expects_shipping_at = data.fetch(:expects_shipping_at, self.expects_shipping_at)
  
  self
end