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.
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 @id = data.fetch(:id, "") @project = data.fetch(:project, nil) @title = data.fetch(:title, "") @content = data.fetch(:content, "") @level = data.fetch(:level, 0) @created_at = data.fetch(:created_at, "") 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
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/processout/activity.rb', line 100 def all( = {}) 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 |
# File 'lib/processout/activity.rb', line 74 def fill_with_data(data) 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
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/processout/activity.rb', line 129 def find(activity_id, = {}) 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 |