class Phraseapp::Rest::Api

Constants

BASE_URL

Public Class Methods

new(rest_client:, token:) click to toggle source
# File lib/phraseapp-rest/api.rb, line 7
def initialize(rest_client:, token:)
  @client = rest_client
  @token = token
end

Public Instance Methods

get(path) click to toggle source
# 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