Sha256: 42172ebec0074c52d78237539e7b85b82de0101a0ced7832bd55d5a437d8d1d9

Contents?: true

Size: 1.17 KB

Versions: 5

Compression:

Stored size: 1.17 KB

Contents

module StellarClient
  class WithdrawResponse < BaseResponse

    BODY_ATTRS = %i[
      account_id
      memo_type
      memo
      min_amount
      max_amount
      fee_fixed
      fee_percent
      fee_network
    ].freeze

    attribute(:body, Coercers::IndifferentHash, {
      lazy: true,
      default: :default_body,
    })
    attribute :account_id, String, lazy: true, default: :default_account_id
    attribute :memo_type, String, lazy: true, default: :default_memo_type
    attribute :memo, String, lazy: true, default: :default_memo
    attribute :min_amount, BigDecimal, lazy: true, default: :default_min_amount
    attribute :max_amount, BigDecimal, lazy: true, default: :default_max_amount
    attribute :fee_fixed, BigDecimal, lazy: true, default: :default_fee_fixed
    attribute(:fee_percent, BigDecimal, {
      lazy: true,
      default: :default_fee_percent,
    })
    attribute(:fee_network, BigDecimal, {
      lazy: true,
      default: :default_fee_network,
    })

    private

    def default_body
      JSON.parse(raw_response.body)
    end

    BODY_ATTRS.each do |attr|
      define_method("default_#{attr}".to_sym) do
        body[attr]
      end
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
stellar_client-0.8.0 lib/stellar_client/responses/withdraw_response.rb
stellar_client-0.7.0 lib/stellar_client/responses/withdraw_response.rb
stellar_client-0.6.1 lib/stellar_client/responses/withdraw_response.rb
stellar_client-0.6.0 lib/stellar_client/responses/withdraw_response.rb
stellar_client-0.5.2 lib/stellar_client/responses/withdraw_response.rb