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.
-
#sandbox ⇒ Object
Returns the value of attribute sandbox.
Instance Method Summary collapse
-
#all(options = nil) ⇒ Object
Get all the events.
-
#fill_with_data(data) ⇒ Object
- Fills the object with data coming from the API Params:
data -
Hashof data coming from the API.
- Fills the object with data coming from the API Params:
-
#find(event_id, options = nil) ⇒ Object
Find an event by its ID.
-
#initialize(client) ⇒ Event
constructor
- Initializes the Event object Params:
client -
ProcessOutclient instance.
- Initializes the Event object Params:
-
#webhooks(options = nil) ⇒ Object
Get all the webhooks of the event.
Constructor Details
#initialize(client) ⇒ Event
Initializes the Event object Params:
client-
ProcessOutclient instance
54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/processout/event.rb', line 54 def initialize(client) @client = client @id = "" @project = nil @name = "" @data = nil @sandbox = false @fired_at = "" end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
13 14 15 |
# File 'lib/processout/event.rb', line 13 def data @data end |
#fired_at ⇒ Object
Returns the value of attribute fired_at.
15 16 17 |
# File 'lib/processout/event.rb', line 15 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.
12 13 14 |
# File 'lib/processout/event.rb', line 12 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 |
#sandbox ⇒ Object
Returns the value of attribute sandbox.
14 15 16 |
# File 'lib/processout/event.rb', line 14 def sandbox @sandbox end |
Instance Method Details
#all(options = nil) ⇒ Object
Get all the events. Params:
options-
Hashof options
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/processout/event.rb', line 123 def all( = nil) 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(@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-
Hashof data coming from the API
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/processout/event.rb', line 69 def fill_with_data(data) if data.include? "id" @id = data["id"] end if data.include? "project" @project = data["project"] end if data.include? "name" @name = data["name"] end if data.include? "data" @data = data["data"] end if data.include? "sandbox" @sandbox = data["sandbox"] end if data.include? "fired_at" @fired_at = data["fired_at"] end self end |
#find(event_id, options = nil) ⇒ Object
Find an event by its ID. Params:
event_id-
ID of the event
options-
Hashof options
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/processout/event.rb', line 152 def find(event_id, = nil) 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 |
#webhooks(options = nil) ⇒ Object
Get all the webhooks of the event. Params:
options-
Hashof options
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/processout/event.rb', line 95 def webhooks( = nil) 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(@client) tmp.fill_with_data(v) a.push(tmp) end return_values.push(a) return_values[0] end |