Class: Courier::Resources::Translations
- Inherits:
-
Object
- Object
- Courier::Resources::Translations
- 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
-
#initialize(client:) ⇒ Translations
constructor
private
A new instance of Translations.
-
#retrieve(locale, domain:, request_options: {}) ⇒ String
Some parameter documentations has been truncated, see Models::TranslationRetrieveParams for more details.
-
#update(locale, domain:, body:, request_options: {}) ⇒ nil
Some parameter documentations has been truncated, see Models::TranslationUpdateParams for more details.
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.
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.
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, = 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: ) 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.
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, = 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: ) end |