Class: ProcessOut::InvoiceShipping
- Inherits:
-
Object
- Object
- ProcessOut::InvoiceShipping
- Defined in:
- lib/processout/invoice_shipping.rb
Instance Attribute Summary collapse
-
#address1 ⇒ Object
Returns the value of attribute address1.
-
#address2 ⇒ Object
Returns the value of attribute address2.
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#city ⇒ Object
Returns the value of attribute city.
-
#country_code ⇒ Object
Returns the value of attribute country_code.
-
#delay ⇒ Object
Returns the value of attribute delay.
-
#expects_shipping_at ⇒ Object
Returns the value of attribute expects_shipping_at.
-
#method ⇒ Object
Returns the value of attribute method.
-
#phone_number ⇒ Object
Returns the value of attribute phone_number.
-
#provider ⇒ Object
Returns the value of attribute provider.
-
#state ⇒ Object
Returns the value of attribute state.
-
#zip ⇒ Object
Returns the value of attribute zip.
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.
- Fills the object with data coming from the API Params:
-
#initialize(client, data = {}) ⇒ InvoiceShipping
constructor
- Initializes the InvoiceShipping object Params:
client ProcessOutclient instancedata-
data that can be used to fill the object.
- Initializes the InvoiceShipping object Params:
-
#new(data = {}) ⇒ Object
Create a new InvoiceShipping using the current client.
-
#prefill(data) ⇒ Object
- Prefills the object with the data passed as parameters Params:
data -
Hashof data.
- Prefills the object with the data passed as parameters Params:
-
#to_json(options) ⇒ Object
Overrides the JSON marshaller to only send the fields we want.
Constructor Details
#initialize(client, data = {}) ⇒ InvoiceShipping
Initializes the InvoiceShipping object Params:
client-
ProcessOutclient instance data-
data that can be used to fill the object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/processout/invoice_shipping.rb', line 78 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
#address1 ⇒ Object
Returns the value of attribute address1.
15 16 17 |
# File 'lib/processout/invoice_shipping.rb', line 15 def address1 @address1 end |
#address2 ⇒ Object
Returns the value of attribute address2.
16 17 18 |
# File 'lib/processout/invoice_shipping.rb', line 16 def address2 @address2 end |
#amount ⇒ Object
Returns the value of attribute amount.
11 12 13 |
# File 'lib/processout/invoice_shipping.rb', line 11 def amount @amount end |
#city ⇒ Object
Returns the value of attribute city.
17 18 19 |
# File 'lib/processout/invoice_shipping.rb', line 17 def city @city end |
#country_code ⇒ Object
Returns the value of attribute country_code.
19 20 21 |
# File 'lib/processout/invoice_shipping.rb', line 19 def country_code @country_code end |
#delay ⇒ Object
Returns the value of attribute delay.
14 15 16 |
# File 'lib/processout/invoice_shipping.rb', line 14 def delay @delay end |
#expects_shipping_at ⇒ Object
Returns the value of attribute expects_shipping_at.
22 23 24 |
# File 'lib/processout/invoice_shipping.rb', line 22 def expects_shipping_at @expects_shipping_at end |
#method ⇒ Object
Returns the value of attribute method.
12 13 14 |
# File 'lib/processout/invoice_shipping.rb', line 12 def method @method end |
#phone_number ⇒ Object
Returns the value of attribute phone_number.
21 22 23 |
# File 'lib/processout/invoice_shipping.rb', line 21 def phone_number @phone_number end |
#provider ⇒ Object
Returns the value of attribute provider.
13 14 15 |
# File 'lib/processout/invoice_shipping.rb', line 13 def provider @provider end |
#state ⇒ Object
Returns the value of attribute state.
18 19 20 |
# File 'lib/processout/invoice_shipping.rb', line 18 def state @state end |
#zip ⇒ Object
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-
Hashof data coming from the API
122 123 124 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 159 160 161 162 163 164 |
# File 'lib/processout/invoice_shipping.rb', line 122 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
97 98 99 |
# File 'lib/processout/invoice_shipping.rb', line 97 def new(data = {}) InvoiceShipping.new(@client, data) end |
#prefill(data) ⇒ Object
Prefills the object with the data passed as parameters Params:
data-
Hashof data
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'lib/processout/invoice_shipping.rb', line 169 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 |
#to_json(options) ⇒ Object
Overrides the JSON marshaller to only send the fields we want
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/processout/invoice_shipping.rb', line 102 def to_json() { "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, "expects_shipping_at": self.expects_shipping_at, }.to_json end |