Class: Courier::AsyncTranslationsClient
- Inherits:
-
Object
- Object
- Courier::AsyncTranslationsClient
- 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:) ⇒ AsyncTranslationsClient constructor
-
#update(domain:, locale:, request:, request_options: nil) ⇒ Void
Update a translation.
Constructor Details
#initialize(request_client:) ⇒ AsyncTranslationsClient
60 61 62 63 |
# File 'lib/trycourier/translations/client.rb', line 60 def initialize(request_client:) # @type [AsyncRequestClient] @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ Object (readonly)
Returns the value of attribute request_client.
56 57 58 |
# File 'lib/trycourier/translations/client.rb', line 56 def request_client @request_client end |
Instance Method Details
#get(domain:, locale:, request_options: nil) ⇒ String
Get translations by locale
71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/trycourier/translations/client.rb', line 71 def get(domain:, locale:, request_options: nil) Async do 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 end |
#update(domain:, locale:, request:, request_options: nil) ⇒ Void
Update a translation
92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/trycourier/translations/client.rb', line 92 def update(domain:, locale:, request:, request_options: nil) Async do @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 end |