Class: Courier::TranslationsClient
- Inherits:
-
Object
- Object
- Courier::TranslationsClient
- Defined in:
- lib/trycourier/translations/client.rb
Instance Attribute Summary collapse
-
#request_client ⇒ Object
readonly
Returns the value of attribute request_client.
Instance Method Summary collapse
-
#get(domain:, locale:, request_options: nil) ⇒ String
Get translations by locale.
- #initialize(request_client:) ⇒ TranslationsClient constructor
-
#update(domain:, locale:, request:, request_options: nil) ⇒ Void
Update a translation.
Constructor Details
#initialize(request_client:) ⇒ TranslationsClient
12 13 14 15 |
# File 'lib/trycourier/translations/client.rb', line 12 def initialize(request_client:) # @type [RequestClient] @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ Object (readonly)
Returns the value of attribute request_client.
8 9 10 |
# File 'lib/trycourier/translations/client.rb', line 8 def request_client @request_client end |
Instance Method Details
#get(domain:, locale:, request_options: nil) ⇒ String
Get translations by locale
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/trycourier/translations/client.rb', line 23 def get(domain:, locale:, request_options: nil) response = @request_client.conn.get("/translations/#{domain}/#{locale}") do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? unless &..nil? req.headers["Authorization"] = . end req.headers = { **req.headers, **(&.additional_headers || {}) }.compact end response.body end |
#update(domain:, locale:, request:, request_options: nil) ⇒ Void
Update a translation
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/trycourier/translations/client.rb', line 42 def update(domain:, locale:, request:, request_options: nil) @request_client.conn.put("/translations/#{domain}/#{locale}") do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? unless &..nil? req.headers["Authorization"] = . end req.headers = { **req.headers, **(&.additional_headers || {}) }.compact req.body = { **(request || {}), **(&.additional_body_parameters || {}) }.compact end end |