Sha256: 633ae81e12bb78c3295c4ba13fcbf30ccdf21bcd3558756f19f776c640c85af2

Contents?: true

Size: 1.53 KB

Versions: 1

Compression:

Stored size: 1.53 KB

Contents

class Invofox::Company < Invofox::Resource
  has_fields name:        :string,
             countryCode: :string,
             taxId:       :string,
             creator:     :string,
             creation:    :time,
             data:        :hash

  class << self
    # TODO allow not required fields; for now we just need this scenario at Quipu
    def list(country_code:, tax_id:)
      Invofox.api_call(
        clazz:  self,
        method: :get,
        path:   "/companies",
        params: {
          countryCode: country_code,
          taxId:       tax_id
        }
      ) do |response_body|
        response_body['result']
      end
    end

    def get(id:)
      Invofox.api_call(
        clazz:  self,
        method: :get,
        path:   "/companies/#{id}"
      ) do |response_body|
        response_body['result']
      end
    end

    def create(country_code:, tax_id:, name:)
      Invofox.api_call(
        clazz:  self,
        method: :post,
        path:   "/companies",
        params: {
          countryCode: country_code,
          taxId:       tax_id,
          name:        name
        }
      ) do |response_body|
        response_body['result']
      end
    end

    def update(id:, country_code:, tax_id:, name:)
      Invofox.api_call(
        clazz:  self,
        method: :put,
        path:   "/companies/#{id}",
        params: {
          countryCode: country_code,
          taxId:       tax_id,
          name:        name
        }
      ) do |response_body|
        response_body['result']
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
invofox-api-ruby-0.1.2 lib/invofox/resources/company.rb