Class: SmartlingApi::Clients::Smartling
- Inherits:
-
Object
- Object
- SmartlingApi::Clients::Smartling
- Defined in:
- lib/smartling_api/clients/smartling.rb
Overview
Client used to contact smartling api
Constant Summary collapse
- SMARTLING_API =
"https://api.smartling.com"
Instance Method Summary collapse
-
#authenticate(url:, body:) ⇒ Hash
Authentication request used to contact Smartling API.
-
#download(url:, token:, params:) ⇒ Hash
Download a file from smartling for the given url.
-
#get(url:, token:, params: {}) ⇒ Hash
Get request used to contact Smartling API.
-
#post(url:, token:, body:) ⇒ Hash
Post request used to contact Smartling API.
-
#upload(url:, token:, body:) ⇒ Hash
Upload a file using a multipart request.
Instance Method Details
#authenticate(url:, body:) ⇒ Hash
Authentication request used to contact Smartling API. Need to pass Smartling id and secret with the request. This is the only request that does not use a token in request.
43 44 45 46 |
# File 'lib/smartling_api/clients/smartling.rb', line 43 def authenticate(url:, body:) response = connection.post(url, body, {}) response.body.fetch("response", {}).fetch("data") end |
#download(url:, token:, params:) ⇒ Hash
Download a file from smartling for the given url
69 70 71 72 |
# File 'lib/smartling_api/clients/smartling.rb', line 69 def download(url:, token:, params:) response = connection.get(url, params, header(token)) response.body end |
#get(url:, token:, params: {}) ⇒ Hash
Get request used to contact Smartling API
18 19 20 21 |
# File 'lib/smartling_api/clients/smartling.rb', line 18 def get(url:, token:, params: {}) response = connection.get(url, params, header(token)) response.body.fetch("response", {}).fetch("data") end |
#post(url:, token:, body:) ⇒ Hash
Post request used to contact Smartling API
30 31 32 33 |
# File 'lib/smartling_api/clients/smartling.rb', line 30 def post(url:, token:, body:) response = connection.post(url, body, header(token)) response.body.fetch("response", {}) end |
#upload(url:, token:, body:) ⇒ Hash
Upload a file using a multipart request
55 56 57 58 59 60 |
# File 'lib/smartling_api/clients/smartling.rb', line 55 def upload(url:, token:, body:) response = multipart_connection.post(url, body, header(token)).body return response if response.is_a?(String) response.fetch('response') end |