Class: Courier::Resources::Brands
- Inherits:
-
Object
- Object
- Courier::Resources::Brands
- Defined in:
- lib/courier/resources/brands.rb,
sig/courier/resources/brands.rbs
Overview
Manage the logos, colors, and layout that give the templates you send a consistent look.
Instance Method Summary collapse
-
#create(name:, settings:, id: nil, snippets: nil, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) ⇒ Courier::Models::Brand
Some parameter documentations has been truncated, see Models::BrandCreateParams for more details.
-
#delete(brand_id, request_options: {}) ⇒ nil
Deletes a brand by id.
-
#initialize(client:) ⇒ Brands
constructor
private
A new instance of Brands.
-
#list(cursor: nil, request_options: {}) ⇒ Courier::Models::BrandListResponse
Lists the workspace's brands.
-
#retrieve(brand_id, request_options: {}) ⇒ Courier::Models::Brand
Returns one brand by id, including its colors, logo and styling settings, Handlebars snippets, and published version.
-
#update(brand_id, name:, settings: nil, snippets: nil, request_options: {}) ⇒ Courier::Models::Brand
Replaces a brand with the values you supply, so send the complete settings and snippets rather than only the fields you want changed.
Constructor Details
#initialize(client:) ⇒ Brands
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Brands.
145 146 147 |
# File 'lib/courier/resources/brands.rb', line 145 def initialize(client:) @client = client end |
Instance Method Details
#create(name:, settings:, id: nil, snippets: nil, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) ⇒ Courier::Models::Brand
Some parameter documentations has been truncated, see Models::BrandCreateParams for more details.
Creates a brand from a name and settings, including primary and secondary colors. Brands supply the logo, colors, and styling that templates render with.
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/courier/resources/brands.rb', line 33 def create(params) parsed, = Courier::BrandCreateParams.dump_request(params) header_params = {idempotency_key: "idempotency-key", x_idempotency_expiration: "x-idempotency-expiration"} @client.request( method: :post, path: "brands", headers: parsed.slice(*header_params.keys).transform_keys(header_params), body: parsed.except(*header_params.keys), model: Courier::Brand, options: ) end |
#delete(brand_id, request_options: {}) ⇒ nil
Deletes a brand by id. Reassign any template or tenant that references it before deleting to keep their styling intact.
133 134 135 136 137 138 139 140 |
# File 'lib/courier/resources/brands.rb', line 133 def delete(brand_id, params = {}) @client.request( method: :delete, path: ["brands/%1$s", brand_id], model: NilClass, options: params[:request_options] ) end |
#list(cursor: nil, request_options: {}) ⇒ Courier::Models::BrandListResponse
Lists the workspace's brands. Every entry carries its name, styling settings, snippets, and published version.
109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/courier/resources/brands.rb', line 109 def list(params = {}) parsed, = Courier::BrandListParams.dump_request(params) query = Courier::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: "brands", query: query, model: Courier::Models::BrandListResponse, options: ) end |
#retrieve(brand_id, request_options: {}) ⇒ Courier::Models::Brand
Returns one brand by id, including its colors, logo and styling settings, Handlebars snippets, and published version.
59 60 61 62 63 64 65 66 |
# File 'lib/courier/resources/brands.rb', line 59 def retrieve(brand_id, params = {}) @client.request( method: :get, path: ["brands/%1$s", brand_id], model: Courier::Brand, options: params[:request_options] ) end |
#update(brand_id, name:, settings: nil, snippets: nil, request_options: {}) ⇒ Courier::Models::Brand
Replaces a brand with the values you supply, so send the complete settings and snippets rather than only the fields you want changed.
86 87 88 89 90 91 92 93 94 95 |
# File 'lib/courier/resources/brands.rb', line 86 def update(brand_id, params) parsed, = Courier::BrandUpdateParams.dump_request(params) @client.request( method: :put, path: ["brands/%1$s", brand_id], body: parsed, model: Courier::Brand, options: ) end |