Class: Trycourier::Resources::Translations

Inherits:
Object
  • Object
show all
Defined in:
lib/trycourier/resources/translations.rb

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:



72
73
74
# File 'lib/trycourier/resources/translations.rb', line 72

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.

Get translations by locale

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 (Trycourier::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

  • (String)

See Also:



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/trycourier/resources/translations.rb', line 22

def retrieve(locale, params)
  parsed, options = Trycourier::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.

Update a translation

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 (Trycourier::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

  • (nil)

See Also:



54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/trycourier/resources/translations.rb', line 54

def update(locale, params)
  parsed, options = Trycourier::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