Sha256: 2d44507335a4f1eb268658eea26d73ffd73ff122ea6b2e33f7ec98e1d163de52

Contents?: true

Size: 1.22 KB

Versions: 5

Compression:

Stored size: 1.22 KB

Contents

require_relative '../onfleet'

module Onfleet
  # A recipient is an organization’s customer and a target for a task, that is, whom the task is being delivered to.
  class Recipients
    def create(config, body)
      method = 'post'
      path = 'recipients'

      Onfleet.request(config, method.to_sym, path, body.to_json)
    end

    def update(config, id, body)
      method = 'put'
      path = "recipients/#{id}"

      Onfleet.request(config, method.to_sym, path, body.to_json)
    end

    def get(config, id)
      method = 'get'
      path = "recipients/#{id}"

      Onfleet.request(config, method.to_sym, path)
    end

    def get_by_name(config, recipient_name)
      method = 'get'
      recipient_name.gsub!(/\s+/, '%20')
      path = "recipients/name/#{recipient_name}"

      Onfleet.request(config, method.to_sym, path)
    end

    def get_by_phone(config, recipient_phone)
      method = 'get'
      path = "recipients/phone/#{recipient_phone}"

      Onfleet.request(config, method.to_sym, path)
    end

    # ACTION: still needs to be tested
    def match_metadata(config, body)
      method = 'post'
      path = 'recipients/metadata'

      Onfleet.request(config, method.to_sym, path, body.to_json)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ruby-onfleet-1.0.5 lib/resources/recipients.rb
ruby-onfleet-1.0.4 lib/resources/recipients.rb
ruby-onfleet-1.0.3 lib/resources/recipients.rb
ruby-onfleet-1.0.2 lib/resources/recipients.rb
ruby-onfleet-1.0.1 lib/resources/recipients.rb