Sha256: 072ecb7667fa2ad0d3dabb35f05349417c6a34db80d82da5a4d55bee212c5ec3

Contents?: true

Size: 611 Bytes

Versions: 2

Compression:

Stored size: 611 Bytes

Contents

# frozen_string_literal: true

module SoapyBing
  class Accounts
    attr_reader :service

    def initialize(*args)
      @service = Service.customer_management(*args)
    end

    def list
      response = service.get_accounts_info
      Array.wrap(response[:accounts_info][:account_info]).map do |account_info|
        build_account(account_info)
      end
    end

    private

    def build_account(account_info)
      Account.new(
        developer_token: service.customer.developer_token,
        customer_id: service.customer.customer_id,
        account_id: account_info[:id]
      )
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
soapy_bing-1.0.1 lib/soapy_bing/accounts.rb
soapy_bing-1.0.0 lib/soapy_bing/accounts.rb