Class: Mitake::Message

Inherits:
Object
  • Object
show all
Includes:
API, Model
Defined in:
lib/mitake/message.rb

Overview

Create Sort Message

Since:

  • 0.1.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Model

#attributes, included

Methods included from API

included

Instance Attribute Details

#bodyString

Returns the message body.

Returns:

  • (String)

    the message body



37
# File 'lib/mitake/message.rb', line 37

attribute :body, String

#duplicateTrueClass|FalseClass (readonly)

Returns is the message duplicate.

Returns:

  • (TrueClass|FalseClass)

    is the message duplicate



53
# File 'lib/mitake/message.rb', line 53

attribute :duplicate, Boolean, readonly: true

#expired_atTime|NilClass

Returns the valid time for this message.

Returns:

  • (Time|NilClass)

    the valid time for this message



45
# File 'lib/mitake/message.rb', line 45

attribute :expired_at, Time

#idString (readonly)

Returns the message id.

Returns:

  • (String)

    the message id



25
# File 'lib/mitake/message.rb', line 25

attribute :id, String, readonly: true

#receipientMitake::Recipient

Returns the message recipient.

Returns:



33
# File 'lib/mitake/message.rb', line 33

attribute :recipient, Recipient

#schedule_atTime|NilClass

Returns the schedule time to send message.

Returns:

  • (Time|NilClass)

    the schedule time to send message



41
# File 'lib/mitake/message.rb', line 41

attribute :schedule_at, Time

#source_idString

Returns the customize identity.

Returns:

  • (String)

    the customize identity



29
# File 'lib/mitake/message.rb', line 29

attribute :source_id, String

#status_codeInteger (readonly)

Returns the status code.

Returns:

  • (Integer)

    the status code



57
# File 'lib/mitake/message.rb', line 57

attribute :status_code, Integer, readonly: true

#webhook_urlString|NilClass

Returns the response callback url.

Returns:

  • (String|NilClass)

    the response callback url



49
# File 'lib/mitake/message.rb', line 49

attribute :webhook_url, String

Instance Method Details

#deliveryObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Send message

Since:

  • 0.1.0



63
64
65
66
67
68
69
70
71
72
# File 'lib/mitake/message.rb', line 63

def delivery
  return self if sent?

  self.class.execute(params) do |items|
    attrs = items&.first&.slice(*self.class.attribute_names)
    assign_attributes(attrs)
  end

  self
end

#duplicate?TrueClass|FalseClass

Does message is duplicate

Returns:

  • (TrueClass|FalseClass)

    is the message duplicate

Since:

  • 0.1.0



88
89
90
# File 'lib/mitake/message.rb', line 88

def duplicate?
  @duplicate == true
end

#sent?TrueClass|FalseClass

Does message is sent

Returns:

  • (TrueClass|FalseClass)

    is the message sent

Since:

  • 0.1.0



79
80
81
# File 'lib/mitake/message.rb', line 79

def sent?
  !@id.nil?
end

#statusString

Readable status code

Returns:

  • (String)

    the status code description

Since:

  • 0.1.0



97
98
99
# File 'lib/mitake/message.rb', line 97

def status
  Status::CODES[@status_code]
end