Sha256: 1652b693e65ea67dc2ef02daf23911880b4f3a96ef47057049be38c2fcc7c889

Contents?: true

Size: 844 Bytes

Versions: 5

Compression:

Stored size: 844 Bytes

Contents

module Moip2
  class CustomerApi
    attr_reader :client

    def initialize(client)
      @client = client
    end

    def base_path
      "/v2/customers"
    end

    def base_path_credit_card
      "/v2/fundinginstruments"
    end

    def show(customer_external_id)
      Resource::Customer.new client, client.get("#{base_path}/#{customer_external_id}")
    end

    def create(customer)
      Resource::Customer.new client, client.post(base_path, customer)
    end

    def add_credit_card(customer_external_id, credit_card)
      Resource::CreditCard.new client, client.post(
        "#{base_path}/#{customer_external_id}/fundinginstruments",
        credit_card,
      )
    end

    def delete_credit_card!(credit_card_id)
      resp = client.delete("#{base_path_credit_card}/#{credit_card_id}")

      resp.success?
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
moip2-1.3.1 lib/moip2/customer_api.rb
moip2-1.2.1 lib/moip2/customer_api.rb
moip2-1.2.0 lib/moip2/customer_api.rb
moip2-1.1.0 lib/moip2/customer_api.rb
moip2-1.0.0 lib/moip2/customer_api.rb