Class: ProcessOut::Webhook

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Initializes the Webhook object Params:

client

ProcessOut client instance

data

data that can be used to fill the object



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/processout/webhook.rb', line 91

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

  self.id = data.fetch(:id, nil)
  self.project = data.fetch(:project, nil)
  self.event = data.fetch(:event, nil)
  self.request_url = data.fetch(:request_url, nil)
  self.request_method = data.fetch(:request_method, nil)
  self.response_body = data.fetch(:response_body, nil)
  self.response_code = data.fetch(:response_code, nil)
  self.response_headers = data.fetch(:response_headers, nil)
  self.response_time_ms = data.fetch(:response_time_ms, nil)
  self.status = data.fetch(:status, nil)
  self.created_at = data.fetch(:created_at, nil)
  self.release_at = data.fetch(:release_at, nil)
  
end

Instance Attribute Details

#created_atObject

Returns the value of attribute created_at.



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

def created_at
  @created_at
end

#eventObject

Returns the value of attribute event.



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

def event
  @event
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#projectObject

Returns the value of attribute project.



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

def project
  @project
end

#release_atObject

Returns the value of attribute release_at.



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

def release_at
  @release_at
end

#request_methodObject

Returns the value of attribute request_method.



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

def request_method
  @request_method
end

#request_urlObject

Returns the value of attribute request_url.



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

def request_url
  @request_url
end

#response_bodyObject

Returns the value of attribute response_body.



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

def response_body
  @response_body
end

#response_codeObject

Returns the value of attribute response_code.



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

def response_code
  @response_code
end

#response_headersObject

Returns the value of attribute response_headers.



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

def response_headers
  @response_headers
end

#response_time_msObject

Returns the value of attribute response_time_ms.



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

def response_time_ms
  @response_time_ms
end

#statusObject

Returns the value of attribute status.



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

def status
  @status
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



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
155
156
157
158
159
# File 'lib/processout/webhook.rb', line 117

def fill_with_data(data)
  if data.nil?
    return self
  end
  if data.include? "id"
    self.id = data["id"]
  end
  if data.include? "project"
    self.project = data["project"]
  end
  if data.include? "event"
    self.event = data["event"]
  end
  if data.include? "request_url"
    self.request_url = data["request_url"]
  end
  if data.include? "request_method"
    self.request_method = data["request_method"]
  end
  if data.include? "response_body"
    self.response_body = data["response_body"]
  end
  if data.include? "response_code"
    self.response_code = data["response_code"]
  end
  if data.include? "response_headers"
    self.response_headers = data["response_headers"]
  end
  if data.include? "response_time_ms"
    self.response_time_ms = data["response_time_ms"]
  end
  if data.include? "status"
    self.status = data["status"]
  end
  if data.include? "created_at"
    self.created_at = data["created_at"]
  end
  if data.include? "release_at"
    self.release_at = data["release_at"]
  end
  
  self
end

#new(data = {}) ⇒ Object

Create a new Webhook using the current client



110
111
112
# File 'lib/processout/webhook.rb', line 110

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

#prefill(data) ⇒ Object

Prefills the object with the data passed as parameters Params:

data

Hash of data



164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'lib/processout/webhook.rb', line 164

def prefill(data)
  if data.nil?
    return self
  end
  self.id = data.fetch(:id, self.id)
  self.project = data.fetch(:project, self.project)
  self.event = data.fetch(:event, self.event)
  self.request_url = data.fetch(:request_url, self.request_url)
  self.request_method = data.fetch(:request_method, self.request_method)
  self.response_body = data.fetch(:response_body, self.response_body)
  self.response_code = data.fetch(:response_code, self.response_code)
  self.response_headers = data.fetch(:response_headers, self.response_headers)
  self.response_time_ms = data.fetch(:response_time_ms, self.response_time_ms)
  self.status = data.fetch(:status, self.status)
  self.created_at = data.fetch(:created_at, self.created_at)
  self.release_at = data.fetch(:release_at, self.release_at)
  
  self
end