Class: ProcessOut::Activity
- Inherits:
-
Object
- Object
- ProcessOut::Activity
- Defined in:
- lib/processout/activity.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#id ⇒ Object
Returns the value of attribute id.
-
#level ⇒ Object
Returns the value of attribute level.
-
#project ⇒ Object
Returns the value of attribute project.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
-
#all(options = {}) ⇒ Object
Get all the project activities.
-
#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(activity_id, options = {}) ⇒ Object
Find a specific activity and fetch its data.
-
#initialize(client, data = {}) ⇒ Activity
constructor
- Initializes the Activity object Params:
client ProcessOutclient instancedata-
data that can be used to fill the object.
- Initializes the Activity object Params:
-
#new(data = {}) ⇒ Object
Create a new Activity using the current client.
-
#prefill(data) ⇒ Object
- Prefills the object with the data passed as parameters Params:
data -
Hashof data.
- Prefills the object with the data passed as parameters Params:
Constructor Details
#initialize(client, data = {}) ⇒ Activity
Initializes the Activity object Params:
client-
ProcessOutclient instance data-
data that can be used to fill the object
54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/processout/activity.rb', line 54 def initialize(client, data = {}) @client = client self.id = data.fetch(:id, nil) self.project = data.fetch(:project, nil) self.title = data.fetch(:title, nil) self.content = data.fetch(:content, nil) self.level = data.fetch(:level, nil) self.created_at = data.fetch(:created_at, nil) end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
13 14 15 |
# File 'lib/processout/activity.rb', line 13 def content @content end |
#created_at ⇒ Object
Returns the value of attribute created_at.
15 16 17 |
# File 'lib/processout/activity.rb', line 15 def created_at @created_at end |
#id ⇒ Object
Returns the value of attribute id.
10 11 12 |
# File 'lib/processout/activity.rb', line 10 def id @id end |
#level ⇒ Object
Returns the value of attribute level.
14 15 16 |
# File 'lib/processout/activity.rb', line 14 def level @level end |
#project ⇒ Object
Returns the value of attribute project.
11 12 13 |
# File 'lib/processout/activity.rb', line 11 def project @project end |
#title ⇒ Object
Returns the value of attribute title.
12 13 14 |
# File 'lib/processout/activity.rb', line 12 def title @title end |
Instance Method Details
#all(options = {}) ⇒ Object
Get all the project activities. Params:
options-
Hashof options
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 |
# File 'lib/processout/activity.rb', line 120 def all( = {}) self.prefill() request = Request.new(@client) path = "/activities" data = { } response = Response.new(request.get(path, data, )) return_values = Array.new a = Array.new body = response.body for v in body['activities'] tmp = Activity.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-
Hashof data coming from the API
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/processout/activity.rb', line 74 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? "title" self.title = data["title"] end if data.include? "content" self.content = data["content"] end if data.include? "level" self.level = data["level"] end if data.include? "created_at" self.created_at = data["created_at"] end self end |
#find(activity_id, options = {}) ⇒ Object
Find a specific activity and fetch its data. Params:
activity_id-
ID of the activity
options-
Hashof options
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/processout/activity.rb', line 151 def find(activity_id, = {}) self.prefill() request = Request.new(@client) path = "/activities/" + CGI.escape(activity_id) + "" data = { } response = Response.new(request.get(path, data, )) return_values = Array.new body = response.body body = body["activity"] obj = Activity.new(@client) return_values.push(obj.fill_with_data(body)) return_values[0] end |
#new(data = {}) ⇒ Object
Create a new Activity using the current client
67 68 69 |
# File 'lib/processout/activity.rb', line 67 def new(data = {}) Activity.new(@client, data) end |
#prefill(data) ⇒ Object
Prefills the object with the data passed as parameters Params:
data-
Hashof data
103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/processout/activity.rb', line 103 def prefill(data) if data.nil? return self end self.id = data.fetch(:id, self.id) self.project = data.fetch(:project, self.project) self.title = data.fetch(:title, self.title) self.content = data.fetch(:content, self.content) self.level = data.fetch(:level, self.level) self.created_at = data.fetch(:created_at, self.created_at) self end |