Class: ProcessOut::CardUpdateRequest
- Inherits:
-
Object
- Object
- ProcessOut::CardUpdateRequest
- Defined in:
- lib/processout/card_update_request.rb
Instance Attribute Summary collapse
-
#preferred_scheme ⇒ Object
Returns the value of attribute preferred_scheme.
-
#update_reason ⇒ Object
Returns the value of attribute update_reason.
-
#update_type ⇒ Object
Returns the value of attribute update_type.
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 = {}) ⇒ CardUpdateRequest
constructor
- Initializes the CardUpdateRequest object Params:
client ProcessOutclient instancedata-
data that can be used to fill the object.
- Initializes the CardUpdateRequest object Params:
-
#new(data = {}) ⇒ Object
Create a new CardUpdateRequest 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.
-
#update(card_id, options = {}) ⇒ Object
Update a card by its ID.
Constructor Details
#initialize(client, data = {}) ⇒ CardUpdateRequest
Initializes the CardUpdateRequest object Params:
client-
ProcessOutclient instance data-
data that can be used to fill the object
33 34 35 36 37 38 39 40 |
# File 'lib/processout/card_update_request.rb', line 33 def initialize(client, data = {}) @client = client self.update_type = data.fetch(:update_type, nil) self.update_reason = data.fetch(:update_reason, nil) self.preferred_scheme = data.fetch(:preferred_scheme, nil) end |
Instance Attribute Details
#preferred_scheme ⇒ Object
Returns the value of attribute preferred_scheme.
13 14 15 |
# File 'lib/processout/card_update_request.rb', line 13 def preferred_scheme @preferred_scheme end |
#update_reason ⇒ Object
Returns the value of attribute update_reason.
12 13 14 |
# File 'lib/processout/card_update_request.rb', line 12 def update_reason @update_reason end |
#update_type ⇒ Object
Returns the value of attribute update_type.
11 12 13 |
# File 'lib/processout/card_update_request.rb', line 11 def update_type @update_type 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
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/processout/card_update_request.rb', line 59 def fill_with_data(data) if data.nil? return self end if data.include? "update_type" self.update_type = data["update_type"] end if data.include? "update_reason" self.update_reason = data["update_reason"] end if data.include? "preferred_scheme" self.preferred_scheme = data["preferred_scheme"] end self end |
#new(data = {}) ⇒ Object
Create a new CardUpdateRequest using the current client
43 44 45 |
# File 'lib/processout/card_update_request.rb', line 43 def new(data = {}) CardUpdateRequest.new(@client, data) end |
#prefill(data) ⇒ Object
Prefills the object with the data passed as parameters Params:
data-
Hashof data
79 80 81 82 83 84 85 86 87 88 |
# File 'lib/processout/card_update_request.rb', line 79 def prefill(data) if data.nil? return self end self.update_type = data.fetch(:update_type, self.update_type) self.update_reason = data.fetch(:update_reason, self.update_reason) self.preferred_scheme = data.fetch(:preferred_scheme, self.preferred_scheme) 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/card_update_request.rb', line 48 def to_json() { "update_type": self.update_type, "update_reason": self.update_reason, "preferred_scheme": self.preferred_scheme, }.to_json end |
#update(card_id, options = {}) ⇒ Object
Update a card by its ID. Params:
card_id-
ID of the card
options-
Hashof options
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/processout/card_update_request.rb', line 94 def update(card_id, = {}) self.prefill() request = Request.new(@client) path = "/cards/" + CGI.escape(card_id) + "" data = { "update_type" => @update_type, "update_reason" => @update_reason, "preferred_scheme" => @preferred_scheme } response = Response.new(request.put(path, data, )) return_values = Array.new body = response.body body = body["card"] return_values.push(self.fill_with_data(body)) return_values[0] end |