class Sendshapes::Client
Attributes
api_key[R]
Public Class Methods
new(api_key, base_url = 'http://widget.sendshapes.com:3000', end_point = 'api3')
click to toggle source
# File lib/sendshapes/client.rb, line 7 def initialize(api_key, base_url = 'http://widget.sendshapes.com:3000', end_point = 'api3') @api_key = api_key @connection = RestClient::Resource.new("#{base_url}/#{end_point}") end
Public Instance Methods
create_transaction(file_path, receiver_email, print_value)
click to toggle source
# File lib/sendshapes/client.rb, line 12 def create_transaction(file_path, receiver_email, print_value) post_data = { stl_file: File.new(file_path), api_key: api_key, token: token, receiver_email: receiver_email, print_value: print_value } post('/api_upload_partner_stl', post_data)['data']['token_link'] end
Protected Instance Methods
get(path, params)
click to toggle source
# File lib/sendshapes/client.rb, line 24 def get(path, params) JSON.parse(@connection[path].get(params: params)) end
post(path, data)
click to toggle source
# File lib/sendshapes/client.rb, line 28 def post(path, data) JSON.parse(@connection[path].post(data)) end
token()
click to toggle source
# File lib/sendshapes/client.rb, line 20 def token @token ||= get('/api_create_partner_token', api_key: api_key)['data']['token'] end