Class: ProcessOut::Event
- Inherits:
-
Object
- Object
- ProcessOut::Event
- Defined in:
- lib/processout/event.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#fired_at ⇒ Object
Returns the value of attribute fired_at.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#project ⇒ Object
Returns the value of attribute project.
-
#project_id ⇒ Object
Returns the value of attribute project_id.
-
#sandbox ⇒ Object
Returns the value of attribute sandbox.
Instance Method Summary collapse
-
#all(options = {}) ⇒ Object
Get all the events.
-
#fetch_webhooks(options = {}) ⇒ Object
Get all the webhooks of the event.
-
#fill_with_data(data) ⇒ Object
- Fills the object with data coming from the API Params:
data
-
Hash
of data coming from the API.
- Fills the object with data coming from the API Params:
-
#find(event_id, options = {}) ⇒ Object
Find an event by its ID.
-
#find_by_resource_id(resource_id, options = {}) ⇒ Object
Find an event by the Resource ID that generated it.
-
#initialize(client, data = {}) ⇒ Event
constructor
- Initializes the Event object Params:
client
ProcessOut
client instancedata
-
data that can be used to fill the object.
- Initializes the Event object Params:
-
#new(data = {}) ⇒ Object
Create a new Event using the current client.
-
#prefill(data) ⇒ Object
- Prefills the object with the data passed as parameters Params:
data
-
Hash
of data.
- Prefills the object with the data passed as parameters Params:
Constructor Details
#initialize(client, data = {}) ⇒ Event
Initializes the Event object Params:
client
-
ProcessOut
client instance data
-
data that can be used to fill the object
65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/processout/event.rb', line 65 def initialize(client, data = {}) @client = client self.id = data.fetch(:id, nil) self.project = data.fetch(:project, nil) self.project_id = data.fetch(:project_id, nil) self.name = data.fetch(:name, nil) self.data = data.fetch(:data, nil) self.sandbox = data.fetch(:sandbox, nil) self.fired_at = data.fetch(:fired_at, nil) end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
14 15 16 |
# File 'lib/processout/event.rb', line 14 def data @data end |
#fired_at ⇒ Object
Returns the value of attribute fired_at.
16 17 18 |
# File 'lib/processout/event.rb', line 16 def fired_at @fired_at end |
#id ⇒ Object
Returns the value of attribute id.
10 11 12 |
# File 'lib/processout/event.rb', line 10 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
13 14 15 |
# File 'lib/processout/event.rb', line 13 def name @name end |
#project ⇒ Object
Returns the value of attribute project.
11 12 13 |
# File 'lib/processout/event.rb', line 11 def project @project end |
#project_id ⇒ Object
Returns the value of attribute project_id.
12 13 14 |
# File 'lib/processout/event.rb', line 12 def project_id @project_id end |
#sandbox ⇒ Object
Returns the value of attribute sandbox.
15 16 17 |
# File 'lib/processout/event.rb', line 15 def sandbox @sandbox end |
Instance Method Details
#all(options = {}) ⇒ Object
Get all the events. Params:
options
-
Hash
of options
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
# File 'lib/processout/event.rb', line 166 def all( = {}) self.prefill() request = Request.new(@client) path = "/events" data = { } response = Response.new(request.get(path, data, )) return_values = Array.new a = Array.new body = response.body for v in body['events'] tmp = Event.new(@client) tmp.fill_with_data(v) a.push(tmp) end return_values.push(a) return_values[0] end |
#fetch_webhooks(options = {}) ⇒ Object
Get all the webhooks of the event. Params:
options
-
Hash
of options
136 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 |
# File 'lib/processout/event.rb', line 136 def fetch_webhooks( = {}) self.prefill() request = Request.new(@client) path = "/events/" + CGI.escape(@id) + "/webhooks" data = { } response = Response.new(request.get(path, data, )) return_values = Array.new a = Array.new body = response.body for v in body['webhooks'] tmp = Webhook.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
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/processout/event.rb', line 86 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? "project_id" self.project_id = data["project_id"] end if data.include? "name" self.name = data["name"] end if data.include? "data" self.data = data["data"] end if data.include? "sandbox" self.sandbox = data["sandbox"] end if data.include? "fired_at" self.fired_at = data["fired_at"] end self end |
#find(event_id, options = {}) ⇒ Object
Find an event by its ID. Params:
event_id
-
ID of the event
options
-
Hash
of options
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
# File 'lib/processout/event.rb', line 197 def find(event_id, = {}) self.prefill() request = Request.new(@client) path = "/events/" + CGI.escape(event_id) + "" data = { } response = Response.new(request.get(path, data, )) return_values = Array.new body = response.body body = body["event"] obj = Event.new(@client) return_values.push(obj.fill_with_data(body)) return_values[0] end |
#find_by_resource_id(resource_id, options = {}) ⇒ Object
Find an event by the Resource ID that generated it. Params:
resource_id
-
Resource ID
options
-
Hash
of options
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 |
# File 'lib/processout/event.rb', line 225 def find_by_resource_id(resource_id, = {}) self.prefill() request = Request.new(@client) path = "/events/by_resource_id/" + CGI.escape(resource_id) + "" data = { } response = Response.new(request.get(path, data, )) return_values = Array.new a = Array.new body = response.body for v in body['events'] tmp = Event.new(@client) tmp.fill_with_data(v) a.push(tmp) end return_values.push(a) return_values[0] end |
#new(data = {}) ⇒ Object
Create a new Event using the current client
79 80 81 |
# File 'lib/processout/event.rb', line 79 def new(data = {}) Event.new(@client, data) end |
#prefill(data) ⇒ Object
Prefills the object with the data passed as parameters Params:
data
-
Hash
of data
118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/processout/event.rb', line 118 def prefill(data) if data.nil? return self end self.id = data.fetch(:id, self.id) self.project = data.fetch(:project, self.project) self.project_id = data.fetch(:project_id, self.project_id) self.name = data.fetch(:name, self.name) self.data = data.fetch(:data, self.data) self.sandbox = data.fetch(:sandbox, self.sandbox) self.fired_at = data.fetch(:fired_at, self.fired_at) self end |