Sha256: fd1ce1f1ec78543c8d05ed869dd5a2de4712248bb3d9445fb4def5d76d98bb76

Contents?: true

Size: 1.96 KB

Versions: 11

Compression:

Stored size: 1.96 KB

Contents

# The content of this file was automatically generated

require "cgi"
require "json"
require "processout/networking/request"
require "processout/networking/response"

module ProcessOut
  class CustomerAction
    
    attr_reader :type
    attr_reader :value
    attr_reader :metadata

    
    def type=(val)
      @type = val
    end
    
    def value=(val)
      @value = val
    end
    
    def metadata=(val)
      @metadata = val
    end
    

    # Initializes the CustomerAction object
    # Params:
    # +client+:: +ProcessOut+ client instance
    # +data+:: data that can be used to fill the object
    def initialize(client, data = {})
      @client = client

      self.type = data.fetch(:type, nil)
      self.value = data.fetch(:value, nil)
      self.metadata = data.fetch(:metadata, nil)
      
    end

    # Create a new CustomerAction using the current client
    def new(data = {})
      CustomerAction.new(@client, data)
    end

    # Overrides the JSON marshaller to only send the fields we want
    def to_json(options)
      {
          "type": self.type,
          "value": self.value,
          "metadata": self.metadata,
      }.to_json
    end

    # Fills the object with data coming from the API
    # Params:
    # +data+:: +Hash+ of data coming from the API
    def fill_with_data(data)
      if data.nil?
        return self
      end
      if data.include? "type"
        self.type = data["type"]
      end
      if data.include? "value"
        self.value = data["value"]
      end
      if data.include? "metadata"
        self.metadata = data["metadata"]
      end
      
      self
    end

    # Prefills the object with the data passed as parameters
    # Params:
    # +data+:: +Hash+ of data
    def prefill(data)
      if data.nil?
        return self
      end
      self.type = data.fetch(:type, self.type)
      self.value = data.fetch(:value, self.value)
      self.metadata = data.fetch(:metadata, self.metadata)
      
      self
    end

    
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
processout-3.2.0 lib/processout/customer_action.rb
processout-3.1.0 lib/processout/customer_action.rb
processout-3.0.0 lib/processout/customer_action.rb
processout-2.31.0 lib/processout/customer_action.rb
processout-2.30.0 lib/processout/customer_action.rb
processout-2.29.0 lib/processout/customer_action.rb
processout-2.28.0 lib/processout/customer_action.rb
processout-2.27.1 lib/processout/customer_action.rb
processout-2.26.0 lib/processout/customer_action.rb
processout-2.25.0 lib/processout/customer_action.rb
processout-2.24.0 lib/processout/customer_action.rb