Class: DesignHuddle::Template
- Inherits:
-
Object
- Object
- DesignHuddle::Template
- Defined in:
- lib/design_huddle/template.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.
-
#default_social_post_text ⇒ Object
Returns the value of attribute default_social_post_text.
-
#dimensions ⇒ Object
Returns the value of attribute dimensions.
-
#internal_project_id ⇒ Object
Returns the value of attribute internal_project_id.
-
#media_type ⇒ Object
Returns the value of attribute media_type.
-
#page_count ⇒ Object
Returns the value of attribute page_count.
-
#preview_url ⇒ Object
Returns the value of attribute preview_url.
-
#primary_template_category ⇒ Object
Returns the value of attribute primary_template_category.
-
#primary_template_category_item ⇒ Object
Returns the value of attribute primary_template_category_item.
-
#project_count ⇒ Object
Returns the value of attribute project_count.
-
#source_project ⇒ Object
Returns the value of attribute source_project.
-
#template_code ⇒ Object
Returns the value of attribute template_code.
-
#template_id ⇒ Object
Returns the value of attribute template_id.
-
#template_status ⇒ Object
Returns the value of attribute template_status.
-
#template_title ⇒ Object
Returns the value of attribute template_title.
-
#thumbnail_url ⇒ Object
Returns the value of attribute thumbnail_url.
-
#user_groups_match_type ⇒ Object
Returns the value of attribute user_groups_match_type.
Class Method Summary collapse
-
.create_template_customization_object(**args) ⇒ Object
TODO: Validate this works for the admin API.
- .fetch(template_id_or_code) ⇒ Object
- .list(**_args) ⇒ Object
- .publish(**args) ⇒ Object
- .retrieve(template_id_or_code) ⇒ Object
- .retrieve_publish_progress(job_id) ⇒ Object
- .upsert(template_id_or_code, **args) ⇒ Object
Instance Method Summary collapse
- #delete ⇒ Object
-
#initialize(template) ⇒ Template
constructor
A new instance of Template.
- #reload ⇒ Object
- #update(**args) ⇒ Object
Constructor Details
#initialize(template) ⇒ Template
Returns a new instance of Template.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/design_huddle/template.rb', line 6 def initialize(template) @template_id = template["template_id"] @template_code = template["template_code"] @template_title = template["template_title"] @default_social_post_text = template["default_social_post_text"] @date_created = template["date_created"] @date_updated = template["date_updated"] @project_count = template["project_count"] @primary_template_category = template["primary_template_category"] @primary_template_category_item = template["primary_template_category_item"] @source_project = template["source_project"] @internal_project_id = template["internal_project_id"] @page_count = template["page_count"] @preview_url = template["preview_url"] @thumbnail_url = template["thumbnail_url"] @media_type = template["media_type"] @template_status = template["template_status"] @user_groups_match_type = template["user_groups_match_type"] @dimensions = template["dimensions"] self end |
Instance Attribute Details
#date_created ⇒ Object
Returns the value of attribute date_created.
3 4 5 |
# File 'lib/design_huddle/template.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/template.rb', line 3 def date_updated @date_updated end |
#default_social_post_text ⇒ Object
Returns the value of attribute default_social_post_text.
3 4 5 |
# File 'lib/design_huddle/template.rb', line 3 def @default_social_post_text end |
#dimensions ⇒ Object
Returns the value of attribute dimensions.
3 4 5 |
# File 'lib/design_huddle/template.rb', line 3 def dimensions @dimensions end |
#internal_project_id ⇒ Object
Returns the value of attribute internal_project_id.
3 4 5 |
# File 'lib/design_huddle/template.rb', line 3 def internal_project_id @internal_project_id end |
#media_type ⇒ Object
Returns the value of attribute media_type.
3 4 5 |
# File 'lib/design_huddle/template.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/template.rb', line 3 def page_count @page_count end |
#preview_url ⇒ Object
Returns the value of attribute preview_url.
3 4 5 |
# File 'lib/design_huddle/template.rb', line 3 def preview_url @preview_url end |
#primary_template_category ⇒ Object
Returns the value of attribute primary_template_category.
3 4 5 |
# File 'lib/design_huddle/template.rb', line 3 def primary_template_category @primary_template_category end |
#primary_template_category_item ⇒ Object
Returns the value of attribute primary_template_category_item.
3 4 5 |
# File 'lib/design_huddle/template.rb', line 3 def primary_template_category_item @primary_template_category_item end |
#project_count ⇒ Object
Returns the value of attribute project_count.
3 4 5 |
# File 'lib/design_huddle/template.rb', line 3 def project_count @project_count end |
#source_project ⇒ Object
Returns the value of attribute source_project.
3 4 5 |
# File 'lib/design_huddle/template.rb', line 3 def source_project @source_project end |
#template_code ⇒ Object
Returns the value of attribute template_code.
3 4 5 |
# File 'lib/design_huddle/template.rb', line 3 def template_code @template_code end |
#template_id ⇒ Object
Returns the value of attribute template_id.
3 4 5 |
# File 'lib/design_huddle/template.rb', line 3 def template_id @template_id end |
#template_status ⇒ Object
Returns the value of attribute template_status.
3 4 5 |
# File 'lib/design_huddle/template.rb', line 3 def template_status @template_status end |
#template_title ⇒ Object
Returns the value of attribute template_title.
3 4 5 |
# File 'lib/design_huddle/template.rb', line 3 def template_title @template_title end |
#thumbnail_url ⇒ Object
Returns the value of attribute thumbnail_url.
3 4 5 |
# File 'lib/design_huddle/template.rb', line 3 def thumbnail_url @thumbnail_url end |
#user_groups_match_type ⇒ Object
Returns the value of attribute user_groups_match_type.
3 4 5 |
# File 'lib/design_huddle/template.rb', line 3 def user_groups_match_type @user_groups_match_type end |
Class Method Details
.create_template_customization_object(**args) ⇒ Object
TODO: Validate this works for the admin API
63 64 65 66 67 68 69 |
# File 'lib/design_huddle/template.rb', line 63 def self.create_template_customization_object(**args) # TODO: Validate this works for the admin API DesignHuddle.client.call( method: :post, path: "/partners/api/templates/customization-objects", payload: args.to_json ) end |
.fetch(template_id_or_code) ⇒ Object
85 86 87 |
# File 'lib/design_huddle/template.rb', line 85 def self.fetch(template_id_or_code) DesignHuddle.client.call(path: "/partners/api/templates/#{template_id_or_code}")["data"] end |
.list(**_args) ⇒ Object
71 72 73 74 75 |
# File 'lib/design_huddle/template.rb', line 71 def self.list(**_args) DesignHuddle.client.call(path: "/partners/api/templates")["data"]["items"].map do |template| Template.new(template) end end |
.publish(**args) ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/design_huddle/template.rb', line 55 def self.publish(**args) DesignHuddle.client.call( method: :post, path: "/partners/api/templates", payload: args.to_json ) end |
.retrieve(template_id_or_code) ⇒ Object
77 78 79 |
# File 'lib/design_huddle/template.rb', line 77 def self.retrieve(template_id_or_code) Template.new(Template.fetch(template_id_or_code)) end |
.retrieve_publish_progress(job_id) ⇒ Object
81 82 83 |
# File 'lib/design_huddle/template.rb', line 81 def self.retrieve_publish_progress(job_id) DesignHuddle.client.call(path: "/partners/api/template/jobs/#{job_id}")["data"] end |
.upsert(template_id_or_code, **args) ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/design_huddle/template.rb', line 47 def self.upsert(template_id_or_code, **args) DesignHuddle.client.call( method: :put, path: "/partners/api/templates/#{template_id_or_code}", payload: args.to_json ) end |
Instance Method Details
#delete ⇒ Object
40 41 42 43 44 45 |
# File 'lib/design_huddle/template.rb', line 40 def delete DesignHuddle.client.call( method: :delete, path: "/partners/api/templates/#{template_id}" ) end |
#reload ⇒ Object
28 29 30 |
# File 'lib/design_huddle/template.rb', line 28 def reload initialize(Template.fetch(template_id)) end |
#update(**args) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/design_huddle/template.rb', line 32 def update(**args) DesignHuddle.client.call( method: :patch, path: "/partners/api/templates/#{template_id}", payload: args.to_json ) end |