Class: Courier::Resources::Brands

Inherits:
Object
  • Object
show all
Defined in:
lib/courier/resources/brands.rb

Instance Method Summary collapse

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.

Parameters:



119
120
121
# File 'lib/courier/resources/brands.rb', line 119

def initialize(client:)
  @client = client
end

Instance Method Details

#create(name:, settings:, id: nil, snippets: nil, request_options: {}) ⇒ Courier::Models::Brand

Create a new brand. Requires ‘name` and `settings` (with at least `colors.primary` and `colors.secondary`).

Parameters:

Returns:

See Also:



20
21
22
23
# File 'lib/courier/resources/brands.rb', line 20

def create(params)
  parsed, options = Courier::BrandCreateParams.dump_request(params)
  @client.request(method: :post, path: "brands", body: parsed, model: Courier::Brand, options: options)
end

#delete(brand_id, request_options: {}) ⇒ nil

Delete a brand by brand ID.

Parameters:

  • brand_id (String)

    A unique identifier associated with the brand you wish to retrieve.

  • request_options (Courier::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

  • (nil)

See Also:



107
108
109
110
111
112
113
114
# File 'lib/courier/resources/brands.rb', line 107

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

Get the list of brands.

Parameters:

  • cursor (String, nil)

    A unique identifier that allows for fetching the next set of brands.

  • request_options (Courier::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



84
85
86
87
88
89
90
91
92
93
94
# File 'lib/courier/resources/brands.rb', line 84

def list(params = {})
  parsed, options = 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: options
  )
end

#retrieve(brand_id, request_options: {}) ⇒ Courier::Models::Brand

Fetch a specific brand by brand ID.

Parameters:

  • brand_id (String)

    A unique identifier associated with the brand you wish to retrieve.

  • request_options (Courier::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



36
37
38
39
40
41
42
43
# File 'lib/courier/resources/brands.rb', line 36

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

Replace an existing brand with the supplied values.

Parameters:

Returns:

See Also:



62
63
64
65
66
67
68
69
70
71
# File 'lib/courier/resources/brands.rb', line 62

def update(brand_id, params)
  parsed, options = Courier::BrandUpdateParams.dump_request(params)
  @client.request(
    method: :put,
    path: ["brands/%1$s", brand_id],
    body: parsed,
    model: Courier::Brand,
    options: options
  )
end