Sha256: 76528199ae8a55afd48832c949f40202a3cd64d850f5cdcedf8ecf17697f69b6

Contents?: true

Size: 1.3 KB

Versions: 1

Compression:

Stored size: 1.3 KB

Contents

module BeeiqAPI
  class Ticket
    attr_accessor :contact_type
    attr_accessor :title
    attr_accessor :body
    attr_accessor :email
    attr_accessor :phone
    attr_accessor :name
    attr_accessor :passport
    attr_accessor :contact_id
    attr_accessor :group_name
    attr_accessor :sla_name
    attr_accessor :channel
    attr_accessor :tag

    def initialize(options = {})
      @contactType = options[:contact_type] || Config::ContactType::CUSTOMER
      @title = options[:title]
      @body = options[:body]
      @email = options[:email]
      @phone = options[:phone]
      @name = options[:name]
      @passport = options[:passport]
      @contact_id = options[:contact_id]
      @group_name = options[:group_name]
      @sla_name = options[:sla_name]
      @channel = options[:channel]
      @tag = options[:tag]

      raise ArgumentError, 'body is required' if @body.to_s.empty?
    end

    def payload
      data = {
        contactType: @contact_type,
        title: @title,
        body: @body,
        email: @email,
        phone: @phone,
        name: @name,
        passport: @passport,
        contactId: @contact_id,
        groupName: @group_name,
        slaName: @sla_name,
        channel: @channel,
        tag: @tag
      }
      data.delete_if { |k, v| v.nil? || v.empty? }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
beeiq_api-0.1.0 lib/beeiq_api/ticket.rb