Sha256: fc00e2c8e17218b2a24459dc08b3a67256e856084d762ca108e58e1ca1d8a770

Contents?: true

Size: 926 Bytes

Versions: 7

Compression:

Stored size: 926 Bytes

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 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_rules
      Resources::InvoiceRule.new(http)
    end

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

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

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

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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
billimatic-client-0.10.2 lib/billimatic/client.rb
billimatic-client-0.10.1 lib/billimatic/client.rb
billimatic-client-0.10.0 lib/billimatic/client.rb
billimatic-client-0.9.0 lib/billimatic/client.rb
billimatic-client-0.8.0 lib/billimatic/client.rb
billimatic-client-0.7.0 lib/billimatic/client.rb
billimatic-client-0.6.0 lib/billimatic/client.rb