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



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

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.



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

def can_pull_transactions
  @can_pull_transactions
end

#can_refundObject

Returns the value of attribute can_refund.



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

def can_refund
  @can_refund
end

#descriptionObject

Returns the value of attribute description.



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

def description
  @description
end

#display_nameObject

Returns the value of attribute display_name.



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

def display_name
  @display_name
end

#flowsObject

Returns the value of attribute flows.



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

def flows
  @flows
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#is_oauth_authenticationObject

Returns the value of attribute is_oauth_authentication.



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

def is_oauth_authentication
  @is_oauth_authentication
end

#logo_urlObject

Returns the value of attribute logo_url.



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

def logo_url
  @logo_url
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#tagsObject

Returns the value of attribute tags.



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

def tags
  @tags
end

#urlObject

Returns the value of attribute url.



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

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



181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# File 'lib/processout/gateway.rb', line 181

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



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'lib/processout/gateway.rb', line 115

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



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

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



159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# File 'lib/processout/gateway.rb', line 159

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

#to_json(options) ⇒ Object

Overrides the JSON marshaller to only send the fields we want



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/processout/gateway.rb', line 96

def to_json(options)
  {
      "id": self.id,
      "name": self.name,
      "display_name": self.display_name,
      "logo_url": self.logo_url,
      "url": self.url,
      "flows": self.flows,
      "tags": self.tags,
      "can_pull_transactions": self.can_pull_transactions,
      "can_refund": self.can_refund,
      "is_oauth_authentication": self.is_oauth_authentication,
      "description": self.description,
  }.to_json
end