Class: Phraseapp::Rest::Api
- Inherits:
-
Object
- Object
- Phraseapp::Rest::Api
- Defined in:
- lib/phraseapp-rest/api.rb
Constant Summary collapse
- BASE_URL =
'https://api.phraseapp.com/api/v2'
Instance Method Summary collapse
- #get(path) ⇒ Object
-
#initialize(rest_client:, token:) ⇒ Api
constructor
A new instance of Api.
Constructor Details
#initialize(rest_client:, token:) ⇒ Api
Returns a new instance of Api.
7 8 9 10 |
# File 'lib/phraseapp-rest/api.rb', line 7 def initialize(rest_client:, token:) @client = rest_client @token = token end |
Instance Method Details
#get(path) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/phraseapp-rest/api.rb', line 12 def get(path) rsp, _err = @client::Request.execute( url: "#{BASE_URL}#{path}", method: :get, user: @token, content_type: :json, accept: :json, verify_ssl: true ) rsp.body rescue @client::ExceptionWithResponse => e return '[]' if e.response.code == 404 raise e end |