Class: DesignHuddle::Project
- Inherits:
-
Object
- Object
- DesignHuddle::Project
- Defined in:
- lib/design_huddle/project.rb
Instance Attribute Summary collapse
-
#date_created ⇒ Object
Returns the value of attribute date_created.
-
#date_updated ⇒ Object
Returns the value of attribute date_updated.
-
#dimensions ⇒ Object
Returns the value of attribute dimensions.
-
#last_edited ⇒ Object
Returns the value of attribute last_edited.
-
#last_opened ⇒ Object
Returns the value of attribute last_opened.
-
#media_type ⇒ Object
Returns the value of attribute media_type.
-
#page_count ⇒ Object
Returns the value of attribute page_count.
-
#project_id ⇒ Object
Returns the value of attribute project_id.
-
#project_status ⇒ Object
Returns the value of attribute project_status.
-
#project_title ⇒ Object
Returns the value of attribute project_title.
-
#template_count ⇒ Object
Returns the value of attribute template_count.
-
#thumbnail_url ⇒ Object
Returns the value of attribute thumbnail_url.
-
#user ⇒ Object
Returns the value of attribute user.
Class Method Summary collapse
- .create(media_type: "print", dimensions: { width: 11, height: 6.5, unit_type: "in" }, template_id: nil, customizations: {}) ⇒ Object
- .fetch(project_id, generate_latest_thumbnail = false) ⇒ Object
- .list(**_args) ⇒ Object
- .retrieve(project_id, generate_latest_thumbnail = false) ⇒ Object
- .retrieve_export_progress(project_id:, job_id:) ⇒ Object
Instance Method Summary collapse
- #delete ⇒ Object
- #export(**args) ⇒ Object
-
#initialize(project) ⇒ Project
constructor
A new instance of Project.
- #reload ⇒ Object
- #retrieve_export_progress(job_id) ⇒ Object
- #update(**args) ⇒ Object
Constructor Details
#initialize(project) ⇒ Project
Returns a new instance of Project.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/design_huddle/project.rb', line 6 def initialize(project) @project_title = project["project_title"] @page_count = project["page_count"] @date_created = project["date_created"] @date_updated = project["date_updated"] @last_edited = project["last_edited"] @last_opened = project["last_opened"] @template_count = project["template_count"] @user = project["user"] @project_id = project["project_id"] @thumbnail_url = project["thumbnail_url"] @media_type = project["media_type"] @project_status = project["project_status"] @dimensions = project["dimensions"] self end |
Instance Attribute Details
#date_created ⇒ Object
Returns the value of attribute date_created.
3 4 5 |
# File 'lib/design_huddle/project.rb', line 3 def date_created @date_created end |
#date_updated ⇒ Object
Returns the value of attribute date_updated.
3 4 5 |
# File 'lib/design_huddle/project.rb', line 3 def date_updated @date_updated end |
#dimensions ⇒ Object
Returns the value of attribute dimensions.
3 4 5 |
# File 'lib/design_huddle/project.rb', line 3 def dimensions @dimensions end |
#last_edited ⇒ Object
Returns the value of attribute last_edited.
3 4 5 |
# File 'lib/design_huddle/project.rb', line 3 def last_edited @last_edited end |
#last_opened ⇒ Object
Returns the value of attribute last_opened.
3 4 5 |
# File 'lib/design_huddle/project.rb', line 3 def last_opened @last_opened end |
#media_type ⇒ Object
Returns the value of attribute media_type.
3 4 5 |
# File 'lib/design_huddle/project.rb', line 3 def media_type @media_type end |
#page_count ⇒ Object
Returns the value of attribute page_count.
3 4 5 |
# File 'lib/design_huddle/project.rb', line 3 def page_count @page_count end |
#project_id ⇒ Object
Returns the value of attribute project_id.
3 4 5 |
# File 'lib/design_huddle/project.rb', line 3 def project_id @project_id end |
#project_status ⇒ Object
Returns the value of attribute project_status.
3 4 5 |
# File 'lib/design_huddle/project.rb', line 3 def project_status @project_status end |
#project_title ⇒ Object
Returns the value of attribute project_title.
3 4 5 |
# File 'lib/design_huddle/project.rb', line 3 def project_title @project_title end |
#template_count ⇒ Object
Returns the value of attribute template_count.
3 4 5 |
# File 'lib/design_huddle/project.rb', line 3 def template_count @template_count end |
#thumbnail_url ⇒ Object
Returns the value of attribute thumbnail_url.
3 4 5 |
# File 'lib/design_huddle/project.rb', line 3 def thumbnail_url @thumbnail_url end |
#user ⇒ Object
Returns the value of attribute user.
3 4 5 |
# File 'lib/design_huddle/project.rb', line 3 def user @user end |
Class Method Details
.create(media_type: "print", dimensions: { width: 11, height: 6.5, unit_type: "in" }, template_id: nil, customizations: {}) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/design_huddle/project.rb', line 61 def self.create(media_type: "print", dimensions: { width: 11, height: 6.5, unit_type: "in" }, template_id: nil, customizations: {}) DesignHuddle.client.call( method: :post, path: "/partners/api/projects", payload: { media_type: media_type, dimensions: dimensions, template_id: template_id, customizations: customizations }.to_json ) end |
.fetch(project_id, generate_latest_thumbnail = false) ⇒ Object
84 85 86 87 88 89 90 91 92 93 |
# File 'lib/design_huddle/project.rb', line 84 def self.fetch(project_id, generate_latest_thumbnail = false) DesignHuddle.client.call( path: "/partners/api/projects/#{project_id}", headers: { params: { generate_latest_thumbnail: generate_latest_thumbnail } } )["data"] end |
.list(**_args) ⇒ Object
74 75 76 77 78 |
# File 'lib/design_huddle/project.rb', line 74 def self.list(**_args) DesignHuddle.client.call(path: "/partners/api/projects")["data"]["items"].map do |project| Project.new(project) end end |
.retrieve(project_id, generate_latest_thumbnail = false) ⇒ Object
80 81 82 |
# File 'lib/design_huddle/project.rb', line 80 def self.retrieve(project_id, generate_latest_thumbnail = false) Project.new(Project.fetch(project_id, generate_latest_thumbnail)) end |
.retrieve_export_progress(project_id:, job_id:) ⇒ Object
54 55 56 57 58 59 |
# File 'lib/design_huddle/project.rb', line 54 def self.retrieve_export_progress(project_id:, job_id:) DesignHuddle.client.call( method: :get, path: "/projects/#{project_id}/export/jobs/#{job_id}" ) end |
Instance Method Details
#delete ⇒ Object
35 36 37 38 39 40 |
# File 'lib/design_huddle/project.rb', line 35 def delete DesignHuddle.client.call( method: :delete, path: "/partners/api/projects/#{project_id}" ) end |
#export(**args) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/design_huddle/project.rb', line 42 def export(**args) DesignHuddle.client.call( method: :post, path: "/partners/api/projects/#{project_id}/export", payload: args.to_json ) end |
#reload ⇒ Object
23 24 25 |
# File 'lib/design_huddle/project.rb', line 23 def reload initialize(Project.fetch(project_id)) end |
#retrieve_export_progress(job_id) ⇒ Object
50 51 52 |
# File 'lib/design_huddle/project.rb', line 50 def retrieve_export_progress(job_id) Project.retrieve_export_progress(project_id: project_id, job_id: job_id) end |
#update(**args) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/design_huddle/project.rb', line 27 def update(**args) DesignHuddle.client.call( method: :patch, path: "/partners/api/projects/#{project_id}", payload: args.to_json ) end |