Class: ProcessOut::Project

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Initializes the Project object Params:

client

ProcessOut client instance

data

data that can be used to fill the object



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/processout/project.rb', line 112

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

  self.id = data.fetch(:id, nil)
  self.supervisor_project = data.fetch(:supervisor_project, nil)
  self.supervisor_project_id = data.fetch(:supervisor_project_id, nil)
  self.api_version = data.fetch(:api_version, nil)
  self.name = data.fetch(:name, nil)
  self.logo_url = data.fetch(:logo_url, nil)
  self.email = data.fetch(:email, nil)
  self.default_currency = data.fetch(:default_currency, nil)
  self.private_key = data.fetch(:private_key, nil)
  self.dunning_configuration = data.fetch(:dunning_configuration, nil)
  self.created_at = data.fetch(:created_at, nil)
  
end

Instance Attribute Details

#api_versionObject

Returns the value of attribute api_version.



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

def api_version
  @api_version
end

#created_atObject

Returns the value of attribute created_at.



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

def created_at
  @created_at
end

#default_currencyObject

Returns the value of attribute default_currency.



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

def default_currency
  @default_currency
end

#dunning_configurationObject

Returns the value of attribute dunning_configuration.



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

def dunning_configuration
  @dunning_configuration
end

#emailObject

Returns the value of attribute email.



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

def email
  @email
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#logo_urlObject

Returns the value of attribute logo_url.



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

def logo_url
  @logo_url
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#private_keyObject

Returns the value of attribute private_key.



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

def private_key
  @private_key
end

#supervisor_projectObject

Returns the value of attribute supervisor_project.



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

def supervisor_project
  @supervisor_project
end

#supervisor_project_idObject

Returns the value of attribute supervisor_project_id.



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

def supervisor_project_id
  @supervisor_project_id
end

Instance Method Details

#fetch_gateway_configurations(options = {}) ⇒ Object

Get all the gateway configurations of the project Params:

options

Hash of options



203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
# File 'lib/processout/project.rb', line 203

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

  request = Request.new(@client)
  path    = "/projects/" + CGI.escape(@id) + "/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



137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# File 'lib/processout/project.rb', line 137

def fill_with_data(data)
  if data.nil?
    return self
  end
  if data.include? "id"
    self.id = data["id"]
  end
  if data.include? "supervisor_project"
    self.supervisor_project = data["supervisor_project"]
  end
  if data.include? "supervisor_project_id"
    self.supervisor_project_id = data["supervisor_project_id"]
  end
  if data.include? "api_version"
    self.api_version = data["api_version"]
  end
  if data.include? "name"
    self.name = data["name"]
  end
  if data.include? "logo_url"
    self.logo_url = data["logo_url"]
  end
  if data.include? "email"
    self.email = data["email"]
  end
  if data.include? "default_currency"
    self.default_currency = data["default_currency"]
  end
  if data.include? "private_key"
    self.private_key = data["private_key"]
  end
  if data.include? "dunning_configuration"
    self.dunning_configuration = data["dunning_configuration"]
  end
  if data.include? "created_at"
    self.created_at = data["created_at"]
  end
  
  self
end

#new(data = {}) ⇒ Object

Create a new Project using the current client



130
131
132
# File 'lib/processout/project.rb', line 130

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

#prefill(data) ⇒ Object

Prefills the object with the data passed as parameters Params:

data

Hash of data



181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# File 'lib/processout/project.rb', line 181

def prefill(data)
  if data.nil?
    return self
  end
  self.id = data.fetch(:id, self.id)
  self.supervisor_project = data.fetch(:supervisor_project, self.supervisor_project)
  self.supervisor_project_id = data.fetch(:supervisor_project_id, self.supervisor_project_id)
  self.api_version = data.fetch(:api_version, self.api_version)
  self.name = data.fetch(:name, self.name)
  self.logo_url = data.fetch(:logo_url, self.logo_url)
  self.email = data.fetch(:email, self.email)
  self.default_currency = data.fetch(:default_currency, self.default_currency)
  self.private_key = data.fetch(:private_key, self.private_key)
  self.dunning_configuration = data.fetch(:dunning_configuration, self.dunning_configuration)
  self.created_at = data.fetch(:created_at, self.created_at)
  
  self
end