Class: ProcessOut::CustomerAction
- Inherits:
-
Object
- Object
- ProcessOut::CustomerAction
- Defined in:
- lib/processout/customer_action.rb
Instance Attribute Summary collapse
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#type ⇒ Object
Returns the value of attribute type.
-
#value ⇒ Object
Returns the value of attribute value.
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 = {}) ⇒ CustomerAction
constructor
- Initializes the CustomerAction object Params:
client
ProcessOut
client instancedata
-
data that can be used to fill the object.
- Initializes the CustomerAction object Params:
-
#new(data = {}) ⇒ Object
Create a new CustomerAction 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 = {}) ⇒ CustomerAction
Initializes the CustomerAction object Params:
client
-
ProcessOut
client instance data
-
data that can be used to fill the object
33 34 35 36 37 38 39 40 |
# File 'lib/processout/customer_action.rb', line 33 def initialize(client, data = {}) @client = client self.type = data.fetch(:type, nil) self.value = data.fetch(:value, nil) self. = data.fetch(:metadata, nil) end |
Instance Attribute Details
#metadata ⇒ Object
Returns the value of attribute metadata.
13 14 15 |
# File 'lib/processout/customer_action.rb', line 13 def @metadata end |
#type ⇒ Object
Returns the value of attribute type.
11 12 13 |
# File 'lib/processout/customer_action.rb', line 11 def type @type end |
#value ⇒ Object
Returns the value of attribute value.
12 13 14 |
# File 'lib/processout/customer_action.rb', line 12 def value @value 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
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/processout/customer_action.rb', line 59 def fill_with_data(data) if data.nil? return self end if data.include? "type" self.type = data["type"] end if data.include? "value" self.value = data["value"] end if data.include? "metadata" self. = data["metadata"] end self end |
#new(data = {}) ⇒ Object
Create a new CustomerAction using the current client
43 44 45 |
# File 'lib/processout/customer_action.rb', line 43 def new(data = {}) CustomerAction.new(@client, data) end |
#prefill(data) ⇒ Object
Prefills the object with the data passed as parameters Params:
data
-
Hash
of data
79 80 81 82 83 84 85 86 87 88 |
# File 'lib/processout/customer_action.rb', line 79 def prefill(data) if data.nil? return self end self.type = data.fetch(:type, self.type) self.value = data.fetch(:value, self.value) self. = data.fetch(:metadata, self.) self end |
#to_json(options) ⇒ Object
Overrides the JSON marshaller to only send the fields we want
48 49 50 51 52 53 54 |
# File 'lib/processout/customer_action.rb', line 48 def to_json() { "type": self.type, "value": self.value, "metadata": self., }.to_json end |