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



57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/processout/gateway.rb', line 57

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.description = data.fetch(:description, nil)
  
end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



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

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

#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

#fill_with_data(data) ⇒ Object

Fills the object with data coming from the API Params:

data

Hash of data coming from the API



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/processout/gateway.rb', line 79

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? "description"
    self.description = data["description"]
  end
  
  self
end

#new(data = {}) ⇒ Object

Create a new Gateway using the current client



72
73
74
# File 'lib/processout/gateway.rb', line 72

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



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

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.description = data.fetch(:description, self.description)
  
  self
end