Class: ProcessOut::Project
- Inherits:
-
Object
- Object
- ProcessOut::Project
- Defined in:
- lib/processout/project.rb
Instance Attribute Summary collapse
-
#api_version ⇒ Object
Returns the value of attribute api_version.
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#default_currency ⇒ Object
Returns the value of attribute default_currency.
-
#dunning_configuration ⇒ Object
Returns the value of attribute dunning_configuration.
-
#email ⇒ Object
Returns the value of attribute email.
-
#id ⇒ Object
Returns the value of attribute id.
-
#logo_url ⇒ Object
Returns the value of attribute logo_url.
-
#name ⇒ Object
Returns the value of attribute name.
-
#private_key ⇒ Object
Returns the value of attribute private_key.
-
#supervisor_project ⇒ Object
Returns the value of attribute supervisor_project.
-
#supervisor_project_id ⇒ Object
Returns the value of attribute supervisor_project_id.
Instance Method Summary collapse
-
#create_supervised(options = {}) ⇒ Object
Create a new supervised project.
-
#delete(options = {}) ⇒ Object
Delete the project.
-
#fetch(options = {}) ⇒ Object
Fetch the current project information.
-
#fetch_supervised(options = {}) ⇒ Object
Get all the supervised projects.
-
#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:
-
#initialize(client, data = {}) ⇒ Project
constructor
- Initializes the Project object Params:
client
ProcessOut
client instancedata
-
data that can be used to fill the object.
- Initializes the Project object Params:
-
#new(data = {}) ⇒ Object
Create a new Project 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:
-
#save(options = {}) ⇒ Object
Save the updated project’s attributes.
-
#to_json(options) ⇒ Object
Overrides the JSON marshaller to only send the fields we want.
Constructor Details
#initialize(client, data = {}) ⇒ Project
Initializes the Project object Params:
client
-
ProcessOut
client instance data
-
data that can be used to fill the object
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/processout/project.rb', line 113 def initialize(client, data = {}) @client = client self.id = data.fetch(:id, nil) self.supervisor_project = data.fetch(:supervisor_project, nil) self.supervisor_project_id = data.fetch(:supervisor_project_id, nil) self.api_version = data.fetch(:api_version, nil) self.name = data.fetch(:name, nil) self.logo_url = data.fetch(:logo_url, nil) self.email = data.fetch(:email, nil) self.default_currency = data.fetch(:default_currency, nil) self.private_key = data.fetch(:private_key, nil) self.dunning_configuration = data.fetch(:dunning_configuration, nil) self.created_at = data.fetch(:created_at, nil) end |
Instance Attribute Details
#api_version ⇒ Object
Returns the value of attribute api_version.
14 15 16 |
# File 'lib/processout/project.rb', line 14 def api_version @api_version end |
#created_at ⇒ Object
Returns the value of attribute created_at.
21 22 23 |
# File 'lib/processout/project.rb', line 21 def created_at @created_at end |
#default_currency ⇒ Object
Returns the value of attribute default_currency.
18 19 20 |
# File 'lib/processout/project.rb', line 18 def default_currency @default_currency end |
#dunning_configuration ⇒ Object
Returns the value of attribute dunning_configuration.
20 21 22 |
# File 'lib/processout/project.rb', line 20 def dunning_configuration @dunning_configuration end |
#email ⇒ Object
Returns the value of attribute email.
17 18 19 |
# File 'lib/processout/project.rb', line 17 def email @email end |
#id ⇒ Object
Returns the value of attribute id.
11 12 13 |
# File 'lib/processout/project.rb', line 11 def id @id end |
#logo_url ⇒ Object
Returns the value of attribute logo_url.
16 17 18 |
# File 'lib/processout/project.rb', line 16 def logo_url @logo_url end |
#name ⇒ Object
Returns the value of attribute name.
15 16 17 |
# File 'lib/processout/project.rb', line 15 def name @name end |
#private_key ⇒ Object
Returns the value of attribute private_key.
19 20 21 |
# File 'lib/processout/project.rb', line 19 def private_key @private_key end |
#supervisor_project ⇒ Object
Returns the value of attribute supervisor_project.
12 13 14 |
# File 'lib/processout/project.rb', line 12 def supervisor_project @supervisor_project end |
#supervisor_project_id ⇒ Object
Returns the value of attribute supervisor_project_id.
13 14 15 |
# File 'lib/processout/project.rb', line 13 def supervisor_project_id @supervisor_project_id end |
Instance Method Details
#create_supervised(options = {}) ⇒ Object
Create a new supervised project. Params:
options
-
Hash
of options
324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 |
# File 'lib/processout/project.rb', line 324 def create_supervised( = {}) self.prefill() request = Request.new(@client) path = "/supervised-projects" data = { "id" => @id, "name" => @name, "default_currency" => @default_currency, "dunning_configuration" => @dunning_configuration, "applepay_settings" => .fetch(:applepay_settings, nil), "public_metadata" => .fetch(:public_metadata, nil) } response = Response.new(request.post(path, data, )) return_values = Array.new body = response.body body = body["project"] return_values.push(self.fill_with_data(body)) return_values[0] end |
#delete(options = {}) ⇒ Object
Delete the project. Be careful! Executing this request will prevent any further interaction with the API that uses this project. Params:
options
-
Hash
of options
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 |
# File 'lib/processout/project.rb', line 273 def delete( = {}) self.prefill() request = Request.new(@client) path = "/projects/{project_id}" data = { } response = Response.new(request.delete(path, data, )) return_values = Array.new return_values.push(response.success) return_values[0] end |
#fetch(options = {}) ⇒ Object
Fetch the current project information. Params:
options
-
Hash
of options
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 |
# File 'lib/processout/project.rb', line 221 def fetch( = {}) self.prefill() request = Request.new(@client) path = "/projects/" + CGI.escape(@id) + "" data = { } response = Response.new(request.get(path, data, )) return_values = Array.new body = response.body body = body["project"] return_values.push(self.fill_with_data(body)) return_values[0] end |
#fetch_supervised(options = {}) ⇒ Object
Get all the supervised projects. Params:
options
-
Hash
of options
294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 |
# File 'lib/processout/project.rb', line 294 def fetch_supervised( = {}) self.prefill() request = Request.new(@client) path = "/supervised-projects" data = { } response = Response.new(request.get(path, data, )) return_values = Array.new a = Array.new body = response.body for v in body['projects'] tmp = Project.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
155 156 157 158 159 160 161 162 163 164 165 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 192 193 194 |
# File 'lib/processout/project.rb', line 155 def fill_with_data(data) if data.nil? return self end if data.include? "id" self.id = data["id"] end if data.include? "supervisor_project" self.supervisor_project = data["supervisor_project"] end if data.include? "supervisor_project_id" self.supervisor_project_id = data["supervisor_project_id"] end if data.include? "api_version" self.api_version = data["api_version"] end if data.include? "name" self.name = data["name"] end if data.include? "logo_url" self.logo_url = data["logo_url"] end if data.include? "email" self.email = data["email"] end if data.include? "default_currency" self.default_currency = data["default_currency"] end if data.include? "private_key" self.private_key = data["private_key"] end if data.include? "dunning_configuration" self.dunning_configuration = data["dunning_configuration"] end if data.include? "created_at" self.created_at = data["created_at"] end self end |
#new(data = {}) ⇒ Object
Create a new Project using the current client
131 132 133 |
# File 'lib/processout/project.rb', line 131 def new(data = {}) Project.new(@client, data) end |
#prefill(data) ⇒ Object
Prefills the object with the data passed as parameters Params:
data
-
Hash
of data
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
# File 'lib/processout/project.rb', line 199 def prefill(data) if data.nil? return self end self.id = data.fetch(:id, self.id) self.supervisor_project = data.fetch(:supervisor_project, self.supervisor_project) self.supervisor_project_id = data.fetch(:supervisor_project_id, self.supervisor_project_id) self.api_version = data.fetch(:api_version, self.api_version) self.name = data.fetch(:name, self.name) self.logo_url = data.fetch(:logo_url, self.logo_url) self.email = data.fetch(:email, self.email) self.default_currency = data.fetch(:default_currency, self.default_currency) self.private_key = data.fetch(:private_key, self.private_key) self.dunning_configuration = data.fetch(:dunning_configuration, self.dunning_configuration) self.created_at = data.fetch(:created_at, self.created_at) self end |
#save(options = {}) ⇒ Object
Save the updated project’s attributes. Params:
options
-
Hash
of options
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 |
# File 'lib/processout/project.rb', line 247 def save( = {}) self.prefill() request = Request.new(@client) path = "/projects/" + CGI.escape(@id) + "" data = { } response = Response.new(request.put(path, data, )) return_values = Array.new body = response.body body = body["project"] return_values.push(self.fill_with_data(body)) return_values[0] end |
#to_json(options) ⇒ Object
Overrides the JSON marshaller to only send the fields we want
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/processout/project.rb', line 136 def to_json() { "id": self.id, "supervisor_project": self.supervisor_project, "supervisor_project_id": self.supervisor_project_id, "api_version": self.api_version, "name": self.name, "logo_url": self.logo_url, "email": self.email, "default_currency": self.default_currency, "private_key": self.private_key, "dunning_configuration": self.dunning_configuration, "created_at": self.created_at, }.to_json end |