Class: Karaden::Param::Message::MessageCreateParams

Inherits:
MessageParams
  • Object
show all
Defined in:
lib/karaden/param/message/message_create_params.rb

Constant Summary

Constants inherited from MessageParams

Karaden::Param::Message::MessageParams::CONTEXT_PATH

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMessageCreateParams

Returns a new instance of MessageCreateParams.



7
8
9
10
11
12
13
14
15
16
# File 'lib/karaden/param/message/message_create_params.rb', line 7

def initialize()
  @service_id = nil
  @to = nil
  @body = nil
  @tags = nil
  @is_shorten = nil
  @scheduled_at = nil
  @limited_at = nil
  super
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



5
6
7
# File 'lib/karaden/param/message/message_create_params.rb', line 5

def body
  @body
end

#is_shortenObject

Returns the value of attribute is_shorten.



5
6
7
# File 'lib/karaden/param/message/message_create_params.rb', line 5

def is_shorten
  @is_shorten
end

#limited_atObject

Returns the value of attribute limited_at.



5
6
7
# File 'lib/karaden/param/message/message_create_params.rb', line 5

def limited_at
  @limited_at
end

#scheduled_atObject

Returns the value of attribute scheduled_at.



5
6
7
# File 'lib/karaden/param/message/message_create_params.rb', line 5

def scheduled_at
  @scheduled_at
end

#service_idObject

Returns the value of attribute service_id.



5
6
7
# File 'lib/karaden/param/message/message_create_params.rb', line 5

def service_id
  @service_id
end

#tagsObject

Returns the value of attribute tags.



5
6
7
# File 'lib/karaden/param/message/message_create_params.rb', line 5

def tags
  @tags
end

#toObject

Returns the value of attribute to.



5
6
7
# File 'lib/karaden/param/message/message_create_params.rb', line 5

def to
  @to
end

Class Method Details

.new_builderObject



72
73
74
# File 'lib/karaden/param/message/message_create_params.rb', line 72

def self.new_builder
  MessageCreateParamsBuilder.new
end

Instance Method Details

#to_dataObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/karaden/param/message/message_create_params.rb', line 22

def to_data
  {
    service_id: @service_id,
    to: @to,
    body: @body,
    'tags[]' => @tags,
    is_shorten: if @is_shorten.nil?
                  nil
                else
                  @is_shorten ? 'true' : 'false'
                end,
    scheduled_at: @scheduled_at&.iso8601,
    limited_at: @limited_at&.iso8601
  }.reject { |_, value| value.nil? }
end

#to_pathObject



18
19
20
# File 'lib/karaden/param/message/message_create_params.rb', line 18

def to_path
  CONTEXT_PATH
end

#validateObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/karaden/param/message/message_create_params.rb', line 38

def validate
  errors = Karaden::Model::KaradenObject.new
  has_error = false

  messages = validate_service_id
  unless messages.empty?
    errors.set_property('service_id', messages)
    has_error = true
  end

  messages = validate_to
  unless messages.empty?
    errors.set_property('to', messages)
    has_error = true
  end

  messages = validate_body
  unless messages.empty?
    errors.set_property('body', messages)
    has_error = true
  end

  if has_error
    e = Karaden::Exception::InvalidParamsException.new
    error = Karaden::Model::Error.new
    error.set_property('object', Karaden::Model::Error::OBJECT_NAME)
    error.set_property('errors', errors)
    e.error = error
    raise e
  end

  self
end