Class: ProcessOut::CardShipping
- Inherits:
-
Object
- Object
- ProcessOut::CardShipping
- Defined in:
- lib/processout/card_shipping.rb
Instance Attribute Summary collapse
-
#address1 ⇒ Object
Returns the value of attribute address1.
-
#address2 ⇒ Object
Returns the value of attribute address2.
-
#city ⇒ Object
Returns the value of attribute city.
-
#country_code ⇒ Object
Returns the value of attribute country_code.
-
#email ⇒ Object
Returns the value of attribute email.
-
#first_name ⇒ Object
Returns the value of attribute first_name.
-
#last_name ⇒ Object
Returns the value of attribute last_name.
-
#phone ⇒ Object
Returns the value of attribute phone.
-
#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
-
Hash
of data coming from the API.
- Fills the object with data coming from the API Params:
-
#initialize(client, data = {}) ⇒ CardShipping
constructor
- Initializes the CardShipping object Params:
client
ProcessOut
client instancedata
-
data that can be used to fill the object.
- Initializes the CardShipping object Params:
-
#new(data = {}) ⇒ Object
Create a new CardShipping using the current client.
-
#prefill(data) ⇒ Object
- Prefills the object with the data passed as parameters Params:
data
-
Hash
of 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 = {}) ⇒ CardShipping
Initializes the CardShipping object Params:
client
-
ProcessOut
client instance data
-
data that can be used to fill the object
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/processout/card_shipping.rb', line 80 def initialize(client, data = {}) @client = client 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 = data.fetch(:phone, 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
#address1 ⇒ Object
Returns the value of attribute address1.
11 12 13 |
# File 'lib/processout/card_shipping.rb', line 11 def address1 @address1 end |
#address2 ⇒ Object
Returns the value of attribute address2.
12 13 14 |
# File 'lib/processout/card_shipping.rb', line 12 def address2 @address2 end |
#city ⇒ Object
Returns the value of attribute city.
13 14 15 |
# File 'lib/processout/card_shipping.rb', line 13 def city @city end |
#country_code ⇒ Object
Returns the value of attribute country_code.
15 16 17 |
# File 'lib/processout/card_shipping.rb', line 15 def country_code @country_code end |
#email ⇒ Object
Returns the value of attribute email.
20 21 22 |
# File 'lib/processout/card_shipping.rb', line 20 def email @email end |
#first_name ⇒ Object
Returns the value of attribute first_name.
18 19 20 |
# File 'lib/processout/card_shipping.rb', line 18 def first_name @first_name end |
#last_name ⇒ Object
Returns the value of attribute last_name.
19 20 21 |
# File 'lib/processout/card_shipping.rb', line 19 def last_name @last_name end |
#phone ⇒ Object
Returns the value of attribute phone.
17 18 19 |
# File 'lib/processout/card_shipping.rb', line 17 def phone @phone end |
#state ⇒ Object
Returns the value of attribute state.
14 15 16 |
# File 'lib/processout/card_shipping.rb', line 14 def state @state end |
#zip ⇒ Object
Returns the value of attribute zip.
16 17 18 |
# File 'lib/processout/card_shipping.rb', line 16 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
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 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/processout/card_shipping.rb', line 120 def fill_with_data(data) if data.nil? return self 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" self.phone = data["phone"] 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 CardShipping using the current client
97 98 99 |
# File 'lib/processout/card_shipping.rb', line 97 def new(data = {}) CardShipping.new(@client, data) end |
#prefill(data) ⇒ Object
Prefills the object with the data passed as parameters Params:
data
-
Hash
of data
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
# File 'lib/processout/card_shipping.rb', line 161 def prefill(data) if data.nil? return self end 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 = data.fetch(:phone, self.phone) 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
102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/processout/card_shipping.rb', line 102 def to_json() { "address1": self.address1, "address2": self.address2, "city": self.city, "state": self.state, "country_code": self.country_code, "zip": self.zip, "phone": self.phone, "first_name": self.first_name, "last_name": self.last_name, "email": self.email, }.to_json end |