Class: BeeiqAPI::Ticket

Inherits:
Object
  • Object
show all
Defined in:
lib/beeiq_api/ticket.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Ticket

Returns a new instance of Ticket.

Raises:

  • (ArgumentError)


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/beeiq_api/ticket.rb', line 16

def initialize(options = {})
  @contact_type = 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

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



5
6
7
# File 'lib/beeiq_api/ticket.rb', line 5

def body
  @body
end

#channelObject

Returns the value of attribute channel.



13
14
15
# File 'lib/beeiq_api/ticket.rb', line 13

def channel
  @channel
end

#contact_idObject

Returns the value of attribute contact_id.



10
11
12
# File 'lib/beeiq_api/ticket.rb', line 10

def contact_id
  @contact_id
end

#contact_typeObject

Returns the value of attribute contact_type.



3
4
5
# File 'lib/beeiq_api/ticket.rb', line 3

def contact_type
  @contact_type
end

#emailObject

Returns the value of attribute email.



6
7
8
# File 'lib/beeiq_api/ticket.rb', line 6

def email
  @email
end

#group_nameObject

Returns the value of attribute group_name.



11
12
13
# File 'lib/beeiq_api/ticket.rb', line 11

def group_name
  @group_name
end

#nameObject

Returns the value of attribute name.



8
9
10
# File 'lib/beeiq_api/ticket.rb', line 8

def name
  @name
end

#passportObject

Returns the value of attribute passport.



9
10
11
# File 'lib/beeiq_api/ticket.rb', line 9

def passport
  @passport
end

#phoneObject

Returns the value of attribute phone.



7
8
9
# File 'lib/beeiq_api/ticket.rb', line 7

def phone
  @phone
end

#sla_nameObject

Returns the value of attribute sla_name.



12
13
14
# File 'lib/beeiq_api/ticket.rb', line 12

def sla_name
  @sla_name
end

#tagObject

Returns the value of attribute tag.



14
15
16
# File 'lib/beeiq_api/ticket.rb', line 14

def tag
  @tag
end

#titleObject

Returns the value of attribute title.



4
5
6
# File 'lib/beeiq_api/ticket.rb', line 4

def title
  @title
end

Instance Method Details

#payloadObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/beeiq_api/ticket.rb', line 33

def payload
  data = {
    contactType: @contact_type,
    title: @title,
    body: @body.to_s.gsub("\n", '<br>'),
    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