Sha256: 817c4f452b05cb3a9ff746a6aa733922c03d5d2105d5db4a903f55992589e30c

Contents?: true

Size: 1.75 KB

Versions: 1

Compression:

Stored size: 1.75 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 InvoiceDevice
    
    attr_reader :channel
    attr_reader :ip_address

    
    def channel=(val)
      @channel = val
    end
    
    def ip_address=(val)
      @ip_address = val
    end
    

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

      self.channel = data.fetch(:channel, nil)
      self.ip_address = data.fetch(:ip_address, nil)
      
    end

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

    # Overrides the JSON marshaller to only send the fields we want
    def to_json(options)
      {
          "channel": self.channel,
          "ip_address": self.ip_address,
      }.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? "channel"
        self.channel = data["channel"]
      end
      if data.include? "ip_address"
        self.ip_address = data["ip_address"]
      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.channel = data.fetch(:channel, self.channel)
      self.ip_address = data.fetch(:ip_address, self.ip_address)
      
      self
    end

    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
processout-2.14.0 lib/processout/invoice_device.rb