Class: ProcessOut::ErrorCodes
- Inherits:
-
Object
- Object
- ProcessOut::ErrorCodes
- Defined in:
- lib/processout/error_codes.rb
Instance Attribute Summary collapse
-
#gateway ⇒ Object
Returns the value of attribute gateway.
Instance Method Summary collapse
-
#all(options = {}) ⇒ Object
Get all error codes.
-
#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 = {}) ⇒ ErrorCodes
constructor
- Initializes the ErrorCodes object Params:
client ProcessOutclient instancedata-
data that can be used to fill the object.
- Initializes the ErrorCodes object Params:
-
#new(data = {}) ⇒ Object
Create a new ErrorCodes 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 = {}) ⇒ ErrorCodes
Initializes the ErrorCodes object Params:
client-
ProcessOutclient instance data-
data that can be used to fill the object
35 36 37 38 39 40 |
# File 'lib/processout/error_codes.rb', line 35 def initialize(client, data = {}) @client = client self.gateway = data.fetch(:gateway, nil) end |
Instance Attribute Details
#gateway ⇒ Object
Returns the value of attribute gateway.
11 12 13 |
# File 'lib/processout/error_codes.rb', line 11 def gateway @gateway end |
Instance Method Details
#all(options = {}) ⇒ Object
Get all error codes. Params:
options-
Hashof options
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/processout/error_codes.rb', line 83 def all( = {}) self.prefill() request = Request.new(@client) path = "/error-codes" data = { } response = Response.new(request.get(path, data, )) return_values = Array.new body = response.body obj = ErrorCodes.new(@client) return_values.push(obj.fill_with_data(body)) return_values[0] end |
#fill_with_data(data) ⇒ Object
Fills the object with data coming from the API Params:
data-
Hashof data coming from the API
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/processout/error_codes.rb', line 57 def fill_with_data(data) if data.nil? return self end if data.include? "gateway" self.gateway = data["gateway"] end self end |
#new(data = {}) ⇒ Object
Create a new ErrorCodes using the current client
43 44 45 |
# File 'lib/processout/error_codes.rb', line 43 def new(data = {}) ErrorCodes.new(@client, data) end |
#prefill(data) ⇒ Object
Prefills the object with the data passed as parameters Params:
data-
Hashof data
71 72 73 74 75 76 77 78 |
# File 'lib/processout/error_codes.rb', line 71 def prefill(data) if data.nil? return self end self.gateway = data.fetch(:gateway, self.gateway) self end |
#to_json(options) ⇒ Object
Overrides the JSON marshaller to only send the fields we want
48 49 50 51 52 |
# File 'lib/processout/error_codes.rb', line 48 def to_json() { "gateway": self.gateway, }.to_json end |