Class: Send

Inherits:
Applications show all
Defined in:
lib/coolsms/send.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Applications

#fields, #set_fields

Constructor Details

#initialize(options = {}) ⇒ Send

Returns a new instance of Send.



74
75
76
# File 'lib/coolsms/send.rb', line 74

def initialize(options = {})
  self.set_fields(options)
end

Instance Attribute Details

#app_versionObject

Application version



66
67
68
# File 'lib/coolsms/send.rb', line 66

def app_version
  @app_version
end

#charsetObject

Charset encoding default: utf8



31
32
33
# File 'lib/coolsms/send.rb', line 31

def charset
  @charset
end

#countryObject

Country Korea : +82 (default)



20
21
22
# File 'lib/coolsms/send.rb', line 20

def country
  @country
end

#datetimeObject

Schedule datetime. Format: YYYYMMDDHHMISS



24
25
26
# File 'lib/coolsms/send.rb', line 24

def datetime
  @datetime
end

#delayObject

Delay value : 0 ~ 20



50
51
52
# File 'lib/coolsms/send.rb', line 50

def delay
  @delay
end

#dev_langObject

Development language



60
61
62
# File 'lib/coolsms/send.rb', line 60

def dev_lang
  @dev_lang
end

#extensionObject

Extension JSON data



46
47
48
# File 'lib/coolsms/send.rb', line 46

def extension
  @extension
end

#force_smsObject

Force SMS true or false



54
55
56
# File 'lib/coolsms/send.rb', line 54

def force_sms
  @force_sms
end

#imageObject

Image JPEG, PNG, GIF < 300KB, 2048x2048 px



9
10
11
# File 'lib/coolsms/send.rb', line 9

def image
  @image
end

#image_encodingObject

Image encoding binary(default), base64



13
14
15
# File 'lib/coolsms/send.rb', line 13

def image_encoding
  @image_encoding
end

#modeObject

Mode if ‘test’

from_num : '010000000'
datetime is ignore
return_value : 60
recharge


42
43
44
# File 'lib/coolsms/send.rb', line 42

def mode
  @mode
end

#os_platformObject

Client OS and platform



57
58
59
# File 'lib/coolsms/send.rb', line 57

def os_platform
  @os_platform
end

#refnameObject

Reference name



16
17
18
# File 'lib/coolsms/send.rb', line 16

def refname
  @refname
end

#sdk_versionObject

SDK version



63
64
65
# File 'lib/coolsms/send.rb', line 63

def sdk_version
  @sdk_version
end

#sender_keyObject

AlarmTalk sender Key



69
70
71
# File 'lib/coolsms/send.rb', line 69

def sender_key
  @sender_key
end

#srkObject

Srk



34
35
36
# File 'lib/coolsms/send.rb', line 34

def srk
  @srk
end

#subjectObject

MMS, LMS subject



27
28
29
# File 'lib/coolsms/send.rb', line 27

def subject
  @subject
end

#template_codeObject

AlarmTalk template code



72
73
74
# File 'lib/coolsms/send.rb', line 72

def template_code
  @template_code
end

#typeObject

Message Type : SMS(default), LMS, MMS, ATA If not +82, force SMS



5
6
7
# File 'lib/coolsms/send.rb', line 5

def type
  @type
end

Instance Method Details

#send(from, to, text) ⇒ Object



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/coolsms/send.rb', line 78

def send(from, to, text)
  fields = self.fields(
    :type, :image, :image_encoding, :refname, :country,
    :datetime, :subject, :charset, :srk, :mode,
    :extension, :delay, :force_sms, :os_platform, :dev_lang,
    :sdk_version, :app_version, :sender_key, :template_code
  )

  fields = fields.merge( from: from, to: to, text: text, type: self.type )

  res = Request.new.post( "send", fields )

  if res.code == "200"
    body = JSON.parse(res.body)
    {
      ret: body['result_code'] == "00",
      message: body['result_message'],
      code: res.code,
      gid: body['group_id']
    }
  else
    {
      ret: false,
      code: res.code
    }
  end
end