Sha256: 6b542164a228969ff4b3e1e498c5b1d6d77b98a550cfa2fe51d6787a81860ef9

Contents?: true

Size: 1.95 KB

Versions: 3

Compression:

Stored size: 1.95 KB

Contents

module GoTransverseTractApi

  module Order

    class People

      def self.find_all
        GoTransverseTractApi.get_response_for(self)
      end

      #
      # @param {Long} eid
      #
      def self.find_by_eid eid
        GoTransverseTractApi.get_response_for(self, {eid: eid})
      end

      #
      # @param {String} first_name
      #
      def self.find_by_first_name first_name
        GoTransverseTractApi.get_response_for(self, {first_name: first_name})
      end

      #
      # @param {String} last_name
      #
      def self.find_by_last_name last_name
        GoTransverseTractApi.get_response_for(self, {last_name: last_name})
      end

      #
      # @param {Long} billing_account_eid
      #
      def self.find_by_billing_account_eid billing_account_eid
        GoTransverseTractApi.get_response_for(self, {billing_account_eid: billing_account_eid})
      end

      #
      # @param {Long} eid
      # @param {Hash} people
      #
      def self.update eid, people
        data = {
          person: {
            eid: eid,
            name: people[:name],
            taxIdNumber: people[:tax_id_number]
          }
        }

        xml_data = GoTransverseTractApi.generateXML(data, 'person')
        GoTransverseTractApi.put_request_for(self, {eid: eid}, xml_data)
      end

      #
      # @param {Long} eid
      # @param {Hash} address
      #
      def self.add_address eid, address
        data = {
          addAddressToParty: {},
          person: {eid: eid},
          postalAddress: {
            purpose: address[:purpose],
            country: address[:country],
            city: address[:city],
            regionOrState: address[:region_or_state],
            postalCode: address[:postal_code],
            line1: address[:line1]
          }
        }

        xml_data = GoTransverseTractApi.generateXML(data, 'addAddressToParty')
        GoTransverseTractApi.post_request_for(self, {eid: eid}, xml_data, "addAddress")
      end

    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gotransverse-tract-api-0.5.2 lib/gotransverse-tract-api/order/people.rb
gotransverse-tract-api-0.5.1 lib/gotransverse-tract-api/order/people.rb
gotransverse-tract-api-0.5.0 lib/gotransverse-tract-api/order/people.rb