Class: Courier::Resources::Translations

Inherits:
Object
  • Object
show all
Defined in:
lib/courier/resources/translations.rb,
sig/courier/resources/translations.rbs

Overview

Store and retrieve the translation strings Courier uses to render localized template content.

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Translations

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 Translations.

Parameters:



76
77
78
# File 'lib/courier/resources/translations.rb', line 76

def initialize(client:)
  @client = client
end

Instance Method Details

#retrieve(locale, domain:, request_options: {}) ⇒ String

Some parameter documentations has been truncated, see Models::TranslationRetrieveParams for more details.

Returns the translation strings stored for one domain and locale, for use in localized notification content.

Parameters:

  • locale (String)

    The locale you want to retrieve the translations for

  • domain (String)

    The domain you want to retrieve translations for. Only default is supported at

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

Returns:

  • (String)

See Also:



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/courier/resources/translations.rb', line 25

def retrieve(locale, params)
  parsed, options = Courier::TranslationRetrieveParams.dump_request(params)
  domain =
    parsed.delete(:domain) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :get,
    path: ["translations/%1$s/%2$s", domain, locale],
    model: String,
    options: options
  )
end

#update(locale, domain:, body:, request_options: {}) ⇒ nil

Some parameter documentations has been truncated, see Models::TranslationUpdateParams for more details.

Uploads the translation strings for one domain and locale. Courier uses them to render localized content for recipients in that locale.

Parameters:

  • locale (String)

    Path param: The locale you want to retrieve the translations for

  • domain (String)

    Path param: The domain you want to retrieve translations for. Only default is

  • body (String)

    Body param

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

Returns:

  • (nil)

See Also:



58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/courier/resources/translations.rb', line 58

def update(locale, params)
  parsed, options = Courier::TranslationUpdateParams.dump_request(params)
  domain =
    parsed.delete(:domain) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :put,
    path: ["translations/%1$s/%2$s", domain, locale],
    body: parsed[:body],
    model: NilClass,
    options: options
  )
end