Sha256: 4703b4e59521ce721e1c0b952454ac142f7c6a63faa8e85600304e3d9ff28e6f

Contents?: true

Size: 857 Bytes

Versions: 3

Compression:

Stored size: 857 Bytes

Contents

module MakePrintable
  class Client
    def base_uri(path='/')
      "https://api.makeprintable.com/v1#{path}"
    end

    def configure_payload(path, opts={})
      base_uri(path) + opts.to_params
    end

    def get_request(uri)
      begin
        Crack::XML.parse RestClient::Request.execute(method: :get, url: uri, headers: {key: self.api_key})
      rescue => e
        Crack::XML.parse e.response
      end
    end

    def post_request(path, opts)
      begin
        Crack::XML.parse RestClient.post(base_uri(path), opts, key: self.api_key)
      rescue => e
        Crack::XML.parse e.response
      end
    end

    def delete_request(uri)
      begin
        Crack::XML.parse RestClient::Request.execute(method: :delete, url: uri, headers: {key: self.api_key})
      rescue => e
        Crack::XML.parse e.response
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
makeprintable-1.0.2 lib/makeprintable/client/endpoints.rb
makeprintable-1.0.1 lib/makeprintable/client/endpoints.rb
makeprintable-1.0.0 lib/makeprintable/client/endpoints.rb