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



42
43
44
45
46
47
48
49
50
51
# File 'lib/processout/project.rb', line 42

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

  self.id = data.fetch(:id, nil)
  self.name = data.fetch(:name, nil)
  self.logo_url = data.fetch(:logo_url, nil)
  self.email = data.fetch(:email, nil)
  self.created_at = data.fetch(:created_at, nil)
  
end

Instance Attribute Details

#created_atObject

Returns the value of attribute created_at.



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

def created_at
  @created_at
end

#emailObject

Returns the value of attribute email.



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

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.



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

def logo_url
  @logo_url
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

Instance Method Details

#fetch_gateway_configurations(options = {}) ⇒ Object

Get all the gateway configurations of the project Params:

options

Hash of options



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
# File 'lib/processout/project.rb', line 103

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



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/processout/project.rb', line 61

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? "logo_url"
    self.logo_url = data["logo_url"]
  end
  if data.include? "email"
    self.email = data["email"]
  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



54
55
56
# File 'lib/processout/project.rb', line 54

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



87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/processout/project.rb', line 87

def prefill(data)
  if data.nil?
    return self
  end
  self.id = data.fetch(:id, self.id)
  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.created_at = data.fetch(:created_at, self.created_at)
  
  self
end