Sha256: 9ceff7e4080654a71b21d8a1cb075e4a6f05781259978cf0d85480a9d02a2416

Contents?: true

Size: 1.41 KB

Versions: 12

Compression:

Stored size: 1.41 KB

Contents

module CurrencyCloud
  class Settlement
    include CurrencyCloud::Resource

    resource :settlements
    actions :create, :retrieve, :find, :delete

    def add_conversion(conversion_id)
      update_attributes(Settlement.add_conversion(id, conversion_id))
    end

    def remove_conversion(conversion_id)
      update_attributes(Settlement.remove_conversion(id, conversion_id))
    end

    def release
      update_attributes(Settlement.release(id))
    end

    def unrelease
      update_attributes(Settlement.unrelease(id))
    end

    def self.add_conversion(settlement_id, conversion_id)
      attrs = client.post("#{settlement_id}/add_conversion", conversion_id: conversion_id)
      new(attrs)
    end

    def self.remove_conversion(settlement_id, conversion_id)
      attrs = client.post("#{settlement_id}/remove_conversion", conversion_id: conversion_id)
      new(attrs)
    end

    def self.release(settlement_id)
      attrs = client.post("#{settlement_id}/release")
      new(attrs)
    end

    def self.unrelease(settlement_id)
      attrs = client.post("#{settlement_id}/unrelease")
      new(attrs)
    end

    private

    def update_attributes(settlement)
      self.conversion_ids = settlement.conversion_ids
      self.status = settlement.status
      self.entries = settlement.entries
      self.updated_at = settlement.updated_at
      self.released_at = settlement.released_at
      self
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
currency_cloud-0.17.7 lib/currency_cloud/settlement.rb
currency_cloud-0.16.2 lib/currency_cloud/settlement.rb
currency_cloud-0.15.8 lib/currency_cloud/settlement.rb
currency_cloud-0.14.2 lib/currency_cloud/settlement.rb
currency_cloud-0.12.5 lib/currency_cloud/settlement.rb
currency_cloud-0.12.4 lib/currency_cloud/settlement.rb
currency_cloud-0.11.2 lib/currency_cloud/settlement.rb
currency_cloud-0.10.0 lib/currency_cloud/settlement.rb
currency_cloud-0.9.0 lib/currency_cloud/settlement.rb
currency_cloud-0.8.2 lib/currency_cloud/settlement.rb
currency_cloud-0.8.0 lib/currency_cloud/settlement.rb
currency_cloud-0.7.2 lib/currency_cloud/settlement.rb