Sha256: 91951548550a98985d4a7bfa5ef9e1cf69964d4aeb671f8a4f0b6ac64744d99b
Contents?: true
Size: 1.4 KB
Versions: 1
Compression:
Stored size: 1.4 KB
Contents
require "fortnox/api/class_methods" require "httparty" module Fortnox module API class Base include HTTParty extend Forwardable extend Fortnox::API::ClassMethods def_delegators self, :set_header, :set_headers, :remove_header, :remove_headers, :validate_base_url, :validate_client_secret, :validate_access_token, :validate_authorization_code def initialize( base_url: nil, client_secret: nil, access_token: nil ) base_url = validate_base_url( base_url ) client_secret = validate_client_secret( client_secret ) access_token = validate_access_token( access_token ) self.class.base_uri( base_url ) set_headers( 'Accept' => 'application/json', 'Client-Secret' => client_secret, 'Access-Token' => access_token, ) end def get( *args ) resp = self.class.get( *args ) # Insert error handling here resp.parsed_response end def put( *args ) resp = self.class.get( *args ) # Insert error handling here resp.parsed_response end def post( *args ) resp = self.class.get( *args ) # Insert error handling here resp.parsed_response end def delete( *args ) resp = self.class.get( *args ) # Insert error handling here resp.parsed_response end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fortnox-api-0.0.2 | lib/fortnox/api/base.rb |