Class: ProcessOut::CardUpdateRequest
- Inherits:
-
Object
- Object
- ProcessOut::CardUpdateRequest
- Defined in:
- lib/processout/card_update_request.rb
Instance Attribute Summary collapse
-
#preferred_card_type ⇒ Object
Returns the value of attribute preferred_card_type.
-
#preferred_scheme ⇒ Object
Returns the value of attribute preferred_scheme.
-
#scheme_details ⇒ Object
Returns the value of attribute scheme_details.
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. -
#initialize(client, data = {}) ⇒ CardUpdateRequest
constructor
Initializes the CardUpdateRequest object Params:
client::ProcessOutclient instancedata:: data that can be used to fill the object. -
#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. -
#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:
clientProcessOutclient instancedatadata that can be used to fill the object
45 46 47 48 49 50 51 52 |
# File 'lib/processout/card_update_request.rb', line 45 def initialize(client, data = {}) @client = client self.preferred_scheme = data.fetch(:preferred_scheme, nil) self.preferred_card_type = data.fetch(:preferred_card_type, nil) self.scheme_details = data.fetch(:scheme_details, nil) end |
Instance Attribute Details
#preferred_card_type ⇒ Object
Returns the value of attribute preferred_card_type.
12 13 14 |
# File 'lib/processout/card_update_request.rb', line 12 def preferred_card_type @preferred_card_type end |
#preferred_scheme ⇒ Object
Returns the value of attribute preferred_scheme.
11 12 13 |
# File 'lib/processout/card_update_request.rb', line 11 def preferred_scheme @preferred_scheme end |
#scheme_details ⇒ Object
Returns the value of attribute scheme_details.
13 14 15 |
# File 'lib/processout/card_update_request.rb', line 13 def scheme_details @scheme_details end |
Instance Method Details
#fill_with_data(data) ⇒ Object
Fills the object with data coming from the API Params:
dataHashof data coming from the API
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/processout/card_update_request.rb', line 71 def fill_with_data(data) if data.nil? return self end if data.include? "preferred_scheme" self.preferred_scheme = data["preferred_scheme"] end if data.include? "preferred_card_type" self.preferred_card_type = data["preferred_card_type"] end if data.include? "scheme_details" self.scheme_details = data["scheme_details"] end self end |
#new(data = {}) ⇒ Object
Create a new CardUpdateRequest using the current client
55 56 57 |
# File 'lib/processout/card_update_request.rb', line 55 def new(data = {}) CardUpdateRequest.new(@client, data) end |
#prefill(data) ⇒ Object
Prefills the object with the data passed as parameters Params:
dataHashof data
91 92 93 94 95 96 97 98 99 100 |
# File 'lib/processout/card_update_request.rb', line 91 def prefill(data) if data.nil? return self end self.preferred_scheme = data.fetch(:preferred_scheme, self.preferred_scheme) self.preferred_card_type = data.fetch(:preferred_card_type, self.preferred_card_type) self.scheme_details = data.fetch(:scheme_details, self.scheme_details) self end |
#to_json(options) ⇒ Object
Overrides the JSON marshaller to only send the fields we want
60 61 62 63 64 65 66 |
# File 'lib/processout/card_update_request.rb', line 60 def to_json() { "preferred_scheme": self.preferred_scheme, "preferred_card_type": self.preferred_card_type, "scheme_details": self.scheme_details, }.to_json end |
#update(card_id, options = {}) ⇒ Object
Update a card by its ID. Params:
card_idID of the card
optionsHashof options
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/processout/card_update_request.rb', line 106 def update(card_id, = {}) self.prefill() request = Request.new(@client) path = "/cards/" + CGI.escape(card_id) + "" data = { "preferred_scheme" => @preferred_scheme, "scheme_details" => @scheme_details } response = Response.new(request.put(path, data, )) return_values = Array.new body = response.body body = body.key?("card") ? body["card"] : nil return_values.push(self.fill_with_data(body)) return_values[0] end |