Sha256: 1f4be30783530989aeb83c4624858e950c4fea5d0b93b23e59310361525c4614

Contents?: true

Size: 1.11 KB

Versions: 4

Compression:

Stored size: 1.11 KB

Contents

module Billimatic
  class Client
    attr_reader :http

    def initialize(token)
      @http = Http.new(token)
    end

    def authenticated?
      http.get("/companies/search?cnpj=auth_test") do |response|
        response.code == 200
      end
    rescue RequestError => e
      raise e unless e.code == 401
      false
    end

    def organizations
      Resources::Organization.new(http)
    end

    def plans
      Resources::Plan.new(http)
    end

    def subscriptions
      Resources::Subscription.new(http)
    end

    def contracts
      Resources::Contract.new(http)
    end

    def invoices
      Resources::Invoice.new(http)
    end

    def invoice_templates
      Resources::InvoiceTemplate.new(http)
    end

    def invoice_rules
      Resources::InvoiceRule.new(http)
    end

    def companies
      Resources::Company.new(http)
    end

    def people
      Resources::Person.new(http)
    end

    def service_items
      Resources::ServiceItem.new(http)
    end

    def webhooks
      Resources::Webhook.new(http)
    end

    def email_templates
      Resources::EmailTemplate.new(http)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
billimatic-client-1.0.1 lib/billimatic/client.rb
billimatic-client-1.0.0 lib/billimatic/client.rb
billimatic-client-0.22.1 lib/billimatic/client.rb
billimatic-client-0.22.0 lib/billimatic/client.rb