Class: ProcessOut::Gateway

Inherits:
Object
  • Object
show all
Defined in:
lib/processout/gateway.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, data = {}) ⇒ Gateway

Initializes the Gateway object Params:

client

ProcessOut client instance

data

data that can be used to fill the object



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/processout/gateway.rb', line 72

def initialize(client, data = {})
  @client = client

  self.id = data.fetch(:id, nil)
  self.name = data.fetch(:name, nil)
  self.display_name = data.fetch(:display_name, nil)
  self.logo_url = data.fetch(:logo_url, nil)
  self.url = data.fetch(:url, nil)
  self.flows = data.fetch(:flows, nil)
  self.tags = data.fetch(:tags, nil)
  self.can_pull_transactions = data.fetch(:can_pull_transactions, nil)
  self.can_refund = data.fetch(:can_refund, nil)
  self.is_oauth_authentication = data.fetch(:is_oauth_authentication, nil)
  self.description = data.fetch(:description, nil)
  
end

Instance Attribute Details

#can_pull_transactionsObject

Returns the value of attribute can_pull_transactions.



17
18
19
# File 'lib/processout/gateway.rb', line 17

def can_pull_transactions
  @can_pull_transactions
end

#can_refundObject

Returns the value of attribute can_refund.



18
19
20
# File 'lib/processout/gateway.rb', line 18

def can_refund
  @can_refund
end

#descriptionObject

Returns the value of attribute description.



20
21
22
# File 'lib/processout/gateway.rb', line 20

def description
  @description
end

#display_nameObject

Returns the value of attribute display_name.



12
13
14
# File 'lib/processout/gateway.rb', line 12

def display_name
  @display_name
end

#flowsObject

Returns the value of attribute flows.



15
16
17
# File 'lib/processout/gateway.rb', line 15

def flows
  @flows
end

#idObject

Returns the value of attribute id.



10
11
12
# File 'lib/processout/gateway.rb', line 10

def id
  @id
end

#is_oauth_authenticationObject

Returns the value of attribute is_oauth_authentication.



19
20
21
# File 'lib/processout/gateway.rb', line 19

def is_oauth_authentication
  @is_oauth_authentication
end

#logo_urlObject

Returns the value of attribute logo_url.



13
14
15
# File 'lib/processout/gateway.rb', line 13

def logo_url
  @logo_url
end

#nameObject

Returns the value of attribute name.



11
12
13
# File 'lib/processout/gateway.rb', line 11

def name
  @name
end

#tagsObject

Returns the value of attribute tags.



16
17
18
# File 'lib/processout/gateway.rb', line 16

def tags
  @tags
end

#urlObject

Returns the value of attribute url.



14
15
16
# File 'lib/processout/gateway.rb', line 14

def url
  @url
end

Instance Method Details

#fetch_gateway_configurations(options = {}) ⇒ Object

Get all the gateway configurations of the gateway Params:

options

Hash of options



163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# File 'lib/processout/gateway.rb', line 163

def fetch_gateway_configurations(options = {})
  self.prefill(options)

  request = Request.new(@client)
  path    = "/gateways/" + CGI.escape(@name) + "/gateway-configurations"
  data    = {

  }

  response = Response.new(request.get(path, data, options))
  return_values = Array.new
  
  a    = Array.new
  body = response.body
  for v in body['gateway_configurations']
    tmp = GatewayConfiguration.new(@client)
    tmp.fill_with_data(v)
    a.push(tmp)
  end

  return_values.push(a)
  

  
  return_values[0]
end

#fill_with_data(data) ⇒ Object

Fills the object with data coming from the API Params:

data

Hash of data coming from the API



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/processout/gateway.rb', line 97

def fill_with_data(data)
  if data.nil?
    return self
  end
  if data.include? "id"
    self.id = data["id"]
  end
  if data.include? "name"
    self.name = data["name"]
  end
  if data.include? "display_name"
    self.display_name = data["display_name"]
  end
  if data.include? "logo_url"
    self.logo_url = data["logo_url"]
  end
  if data.include? "url"
    self.url = data["url"]
  end
  if data.include? "flows"
    self.flows = data["flows"]
  end
  if data.include? "tags"
    self.tags = data["tags"]
  end
  if data.include? "can_pull_transactions"
    self.can_pull_transactions = data["can_pull_transactions"]
  end
  if data.include? "can_refund"
    self.can_refund = data["can_refund"]
  end
  if data.include? "is_oauth_authentication"
    self.is_oauth_authentication = data["is_oauth_authentication"]
  end
  if data.include? "description"
    self.description = data["description"]
  end
  
  self
end

#new(data = {}) ⇒ Object

Create a new Gateway using the current client



90
91
92
# File 'lib/processout/gateway.rb', line 90

def new(data = {})
  Gateway.new(@client, data)
end

#prefill(data) ⇒ Object

Prefills the object with the data passed as parameters Params:

data

Hash of data



141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/processout/gateway.rb', line 141

def prefill(data)
  if data.nil?
    return self
  end
  self.id = data.fetch(:id, self.id)
  self.name = data.fetch(:name, self.name)
  self.display_name = data.fetch(:display_name, self.display_name)
  self.logo_url = data.fetch(:logo_url, self.logo_url)
  self.url = data.fetch(:url, self.url)
  self.flows = data.fetch(:flows, self.flows)
  self.tags = data.fetch(:tags, self.tags)
  self.can_pull_transactions = data.fetch(:can_pull_transactions, self.can_pull_transactions)
  self.can_refund = data.fetch(:can_refund, self.can_refund)
  self.is_oauth_authentication = data.fetch(:is_oauth_authentication, self.is_oauth_authentication)
  self.description = data.fetch(:description, self.description)
  
  self
end