Sha256: e16dddeeb3ce1397eaaec875a97c57302a14bf7d4db4f6b5f5c8edd177380d43

Contents?: true

Size: 1.63 KB

Versions: 85

Compression:

Stored size: 1.63 KB

Contents

module FbGraph
  class Order < Node
    attr_accessor :application, :from, :to, :amount, :status, :country, :created_time, :updated_time

    def initialize(identifier, attributes = {})
      super
      if app = attributes[:application]
        @application = Application.new(app[:id], app)
      end
      if from = attributes[:from]
        @from = User.new(from[:id], from)
      end
      if to = attributes[:to]
        @to = User.new(to[:id], to)
      end
      @amount = attributes[:amount]
      @status = attributes[:status]
      @country = attributes[:country]
      if attributes[:created_time]
        @created_time = Time.parse(attributes[:created_time]).utc
      end
      if attributes[:updated_time]
        @updated_time = Time.parse(attributes[:updated_time]).utc
      end
    end

    def settle!(options = {})
      update options.merge(:status => :settled)
    end
    alias_method :settled!, :settle!

    def refund!(options = {})
      update options.merge(:status => :refunded)
    end
    alias_method :refunded!, :refund!

    def cancel!(options = {})
      update options.merge(:status => :canceled)
    end
    alias_method :canceled!, :cancel!

    def update(attributes = {})
      _attributes_ = attributes.dup
      params = {
        :access_token => _attributes_.delete(:access_token) || self.access_token,
        :status => _attributes_.delete(:status),
        :message => _attributes_.delete(:message),
        :refund_funding_source => _attributes_.delete(:refund_funding_source),
        :refund_reason => _attributes_.delete(:refund_reason),
        :params => _attributes_
      }
      super params
    end
  end
end

Version data entries

85 entries across 85 versions & 1 rubygems

Version Path
fb_graph-2.7.17 lib/fb_graph/order.rb
fb_graph-2.7.16 lib/fb_graph/order.rb
fb_graph-2.7.15 lib/fb_graph/order.rb
fb_graph-2.7.14 lib/fb_graph/order.rb
fb_graph-2.7.13 lib/fb_graph/order.rb
fb_graph-2.7.12 lib/fb_graph/order.rb
fb_graph-2.7.11 lib/fb_graph/order.rb
fb_graph-2.7.10 lib/fb_graph/order.rb
fb_graph-2.7.9 lib/fb_graph/order.rb
fb_graph-2.7.8 lib/fb_graph/order.rb
fb_graph-2.7.7 lib/fb_graph/order.rb
fb_graph-2.7.6 lib/fb_graph/order.rb
fb_graph-2.7.5 lib/fb_graph/order.rb
fb_graph-2.7.4 lib/fb_graph/order.rb
fb_graph-2.7.3 lib/fb_graph/order.rb
fb_graph-2.7.2 lib/fb_graph/order.rb
fb_graph-2.7.1 lib/fb_graph/order.rb
fb_graph-2.7.0 lib/fb_graph/order.rb
fb_graph-2.6.7 lib/fb_graph/order.rb
fb_graph-2.6.6 lib/fb_graph/order.rb