sms_masking 0.1.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b494adf46d071e7ff172e8b9d23cf1c5faf55704
4
- data.tar.gz: 5c3d92d08d12b4ec3c27196a38ce1f3322a312fc
3
+ metadata.gz: 205a16f3061343713fc0fb72574a75cff1bce6b7
4
+ data.tar.gz: 31a933717fb885da39baa7c459d62e0200ebe4ea
5
5
  SHA512:
6
- metadata.gz: 99246403049676e0900a56e5c5d53fb84a379dcec73f9b76ef13f7bc8751459cfb2246ea7cba6311faf4f53d675f8ad99be81b4be42064dd336715d670cd9cfb
7
- data.tar.gz: 0a23160cd262e222b44e7d6fdd558346cfdf42cc94af5400ca13f471582cb5a6a85384ca4a09ce4bf27596e3848cd1f378687d2976bcb34d5a21f4d26eb66092
6
+ metadata.gz: 4351c62d05964d4ef8fc454e4135e1d37d6af55270a733994151c2a134a90126345d395f7f35571ad654b1b4b05ac011403edf6e74aa91e9a65723743572c8ff
7
+ data.tar.gz: aadf3565285755c5332c4ce297f13a91f907c8413377a124b0f81a5a02e461dd14ffcb72a86500a98024385a5f7b42bd0a3cbdb636ef9ed8a6764a7065a54888
data/.DS_Store CHANGED
Binary file
data/README.md CHANGED
@@ -6,6 +6,21 @@ SmsMasking allows you to send SMS messages from your Ruby application using serv
6
6
 
7
7
  This is not official gem of [www.smsmasking.co.id](http://www.smsmasking.co.id/).
8
8
 
9
+ # Index
10
+
11
+ * [Installation](https://github.com/yunanhelmy/sms_masking#installation)
12
+ * [Initialize](https://github.com/yunanhelmy/sms_masking#initialize)
13
+ * [Send an SMS](https://github.com/yunanhelmy/sms_masking#send-an-sms)
14
+ * [Send SMS by Group](https://github.com/yunanhelmy/sms_masking#send-sms-by-group)
15
+ * [Add Phone Book](https://github.com/yunanhelmy/sms_masking#add-phone-book)
16
+ * [Edit Phone Book](https://github.com/yunanhelmy/sms_masking#edit-phone-book)
17
+ * [Delete Phone Book](https://github.com/yunanhelmy/sms_masking#delete-phone-book)
18
+ * [Get Contact List](https://github.com/yunanhelmy/sms_masking#get-contact-list)
19
+ * [Get Contact List by Group](https://github.com/yunanhelmy/sms_masking#get-contact-list-by-group)
20
+ * [Get Complete Data](https://github.com/yunanhelmy/sms_masking#get-complete-data)
21
+ * [Find Name](https://github.com/yunanhelmy/sms_masking#find-name)
22
+ * [Find Phone Number](https://github.com/yunanhelmy/sms_masking#find-phone-number)
23
+
9
24
  ## Installation
10
25
 
11
26
  Add this line to your application's Gemfile:
@@ -24,17 +39,183 @@ Or install it yourself as:
24
39
 
25
40
  ## Usage
26
41
 
27
- ### Initalize
42
+ ### Initialize
28
43
 
29
44
  ```ruby
30
45
  sms = SmsMasking::Base.new(username: "your_username", password: "your_password")
31
46
  ```
32
47
 
33
- ### Send SMS
48
+ Parameters :
49
+
50
+ * `mobile` : recipient
51
+ * `message` : SMS
52
+
53
+ ### Send an SMS
54
+
55
+ Purpose : To Send an SMS
56
+
57
+ Example :
58
+
34
59
  ```ruby
35
60
  sms.send_sms({mobile: "085699999999", message: "your_message"})
36
61
  ```
37
62
 
63
+ Parameters :
64
+
65
+ - `mobile` : recipient number
66
+ - `message` : SMS
67
+
68
+ ### Send SMS by Group
69
+
70
+ Purpose : To Send SMS to a Group
71
+
72
+ Example :
73
+
74
+ ```ruby
75
+ sms.send_sms_group({group: "My group", msg: "your_message"})
76
+ ```
77
+
78
+ Parameters :
79
+
80
+ * `group` : Group Name
81
+ * `message` : SMS
82
+
83
+ ### Add Phone Book
84
+
85
+ Purpose : Add new contact to phone book
86
+
87
+ Example :
88
+
89
+ ```ruby
90
+ sms.add_phone_book({
91
+ name: "John Doe",
92
+ mobile: "085699999999",
93
+ group: "My Group",
94
+ address: "My Address",
95
+ birth: "19900101",
96
+ desc: "My Description"
97
+ })
98
+ ```
99
+
100
+ Parameters :
101
+
102
+ * `name` : Contact Name
103
+ * `mobile` : Recipient
104
+ * `group` : Contact Group Name
105
+ * `address` (optional) : Contact Address
106
+ * `birth` (optional) : Contact Birthday (YYYYMMDD)
107
+ * `desc` (optional) : Contact Description
108
+
109
+ ### Edit Phone Book
110
+
111
+ Purpose : Edit existing Contact
112
+
113
+ Example :
114
+
115
+ ```ruby
116
+ sms.edit_phone_book({
117
+ id: 1,
118
+ name: "John Doe",
119
+ mobile: "085699999999",
120
+ group: "My Group",
121
+ address: "My Address",
122
+ birth: "19900101",
123
+ desc: "My Description"
124
+ })
125
+ ```
126
+
127
+ Parameters :
128
+
129
+ * `id` : Contact ID Number
130
+ * `name` : Contact Name
131
+ * `mobile` : Recipient
132
+ * `group` : Contact Group Name
133
+ * `address` (optional) : Contact Address
134
+ * `birth` (optional) : Contact Birthday (YYYYMMDD)
135
+ * `desc` (optional) : Contact Description
136
+
137
+ ### Delete Phone Book
138
+
139
+ Purpose : Delete existing contact
140
+
141
+ Example :
142
+
143
+ ```ruby
144
+ sms.delete_phone_book({id: 1})
145
+ ```
146
+
147
+ Parameters :
148
+
149
+ * `id` : Contact ID Number
150
+
151
+ ### Get Contact List
152
+
153
+ ```ruby
154
+ sms.list_phone_book({
155
+ page: 1,
156
+ size: 10
157
+ })
158
+ ```
159
+
160
+ Parameters :
161
+
162
+ * `page` : Page Number (default=1)
163
+ * `size` : number of records per page (default=10)
164
+
165
+ ### Get Contact List by Group
166
+
167
+ Purpose : To get Contact list by Group Name
168
+
169
+ ```ruby
170
+ sms.list_phone_book_by_group({
171
+ page: 1,
172
+ size: 10,
173
+ group: "My Group"
174
+ })
175
+ ```
176
+
177
+ Parameters :
178
+
179
+ * `page` : Page Number (default=1)
180
+ * `size` : number of records per page (default=10)
181
+ * `group` : Group Name
182
+
183
+ ### Get Complete Data
184
+
185
+ Purpose : To retrieve contact detail
186
+
187
+ ```ruby
188
+ sms.contact_detail({id: 1})
189
+ ```
190
+
191
+ Parameters :
192
+
193
+ * `id` : Contact ID Number
194
+
195
+ ### Find Name
196
+
197
+ Purpose : To search contact by name
198
+
199
+ ```ruby
200
+ sms.find_contact({name: "John Doe"})
201
+ ```
202
+
203
+ Parameters :
204
+
205
+ * `name` : Name to search
206
+
207
+ ### Find Phone Number
208
+
209
+ Purpose : To search contact by Phone Number
210
+
211
+ ```ruby
212
+ sms.find_contact({number: "085699999999"})
213
+ ```
214
+
215
+ Parameters :
216
+
217
+ * `number` : Number to search
218
+
38
219
  ## Development
39
220
 
40
221
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -43,7 +224,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
43
224
 
44
225
  ## Contributing
45
226
 
46
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/sms_masking. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
227
+ Bug reports and pull requests are welcome on GitHub at https://github.com/yunanhelmy/sms_masking. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
47
228
 
48
229
 
49
230
  ## License
@@ -1,7 +1,7 @@
1
1
  module SmsMasking
2
2
  module Auth
3
- def auth(recipient)
4
- Digest::MD5.hexdigest(@username.to_s+@password.to_s+recipient.to_s)
3
+ def auth(data)
4
+ Digest::MD5.hexdigest(data)
5
5
  end
6
6
  end
7
7
  end
@@ -1,20 +1,24 @@
1
1
  require 'sms_masking/auth'
2
2
  require 'sms_masking/response'
3
3
  require 'sms_masking/send_sms'
4
+ require 'sms_masking/phone_book'
4
5
 
5
6
  module SmsMasking
6
7
  class Base
7
8
  attr_accessor :username
8
9
  attr_accessor :password
10
+ attr_accessor :base_path
9
11
 
10
12
  include HTTParty
11
13
  include SmsMasking::Auth
12
14
  include SmsMasking::SendSms
15
+ include SmsMasking::PhoneBook
13
16
  include SmsMasking::Response
14
17
 
15
18
  base_uri 'http://send.smsmasking.co.id:8080'
16
19
 
17
20
  def initialize(params = {})
21
+ @base_path = "/Web2SMS/api"
18
22
  params.each do |key, value|
19
23
  instance_variable_set("@#{key}", value)
20
24
  end
@@ -0,0 +1,149 @@
1
+ module SmsMasking
2
+ module PhoneBook
3
+
4
+ # ==== Attributes
5
+ # * +name+ : Contact Name
6
+ # * +mobile+ : Recipient
7
+ # * +group+ : Contact Group Name
8
+ # * +address+ (optional) : Contact Address
9
+ # * +birth+ (optional) : Contact Birthday (YYYYMMDD)
10
+ # * +desc+ (optional) : Contact Description
11
+ #
12
+ # ==== Example
13
+ # sms.add_phone_book({
14
+ # name: "John Doe",
15
+ # mobile: "085699999999",
16
+ # group: "My Group",
17
+ # address: "My Address",
18
+ # birth: "19900101",
19
+ # desc: "My Description"
20
+ # })
21
+ #
22
+ def add_phone_book(params = {})
23
+ params[:username] = @username
24
+ params[:auth] = auth(params[:mobile]+@password.to_s)
25
+ res = self.class.get(@base_path+"/phbkAdd.aspx", query: params)
26
+ print_response res
27
+ end
28
+
29
+ # ==== Attributes
30
+ # * +id+ : Contact ID Number
31
+ # * +name+ : Contact Name
32
+ # * +mobile+ : Recipient
33
+ # * +group+ : Contact Group Name
34
+ # * +address+ (optional) : Contact Address
35
+ # * +birth+ (optional) : Contact Birthday (YYYYMMDD)
36
+ # * +desc+ (optional) : Contact Description
37
+ #
38
+ # ==== Example
39
+ # sms.edit_phone_book({
40
+ # id: 1,
41
+ # name: "John Doe",
42
+ # mobile: "085699999999",
43
+ # group: "My Group",
44
+ # address: "My Address",
45
+ # birth: "19900101",
46
+ # desc: "My Description"
47
+ # })
48
+ #
49
+ def edit_phone_book(params = {})
50
+ params[:username] = @username
51
+ params[:auth] = auth(params[:id].to_s+@password.to_s)
52
+ res = self.class.get(@base_path+"/phbkEdit.aspx", query: params)
53
+ print_response res
54
+ end
55
+
56
+ # ==== Attributes
57
+ # * +id+ : Contact ID Number
58
+ #
59
+ # ==== Example
60
+ # sms.delete_phone_book({id: 1})
61
+ #
62
+ def delete_phone_book(params = {})
63
+ params[:username] = @username
64
+ params[:auth] = auth(params[:id].to_s+@password.to_s)
65
+ res = self.class.get(@base_path+"/phbkDelete.aspx", query: params)
66
+ print_response res
67
+ end
68
+
69
+ # ==== Attributes
70
+ # * +page+ : Page Number (default=1)
71
+ # * +size+ : number of records per page (default=10)
72
+ #
73
+ # ==== Example
74
+ # sms.list_phone_book({
75
+ # page: 1,
76
+ # size: 10
77
+ # })
78
+ #
79
+ def list_phone_book(params = {})
80
+ params[:username] = @username
81
+ params[:auth] = auth(@username.to_s+@password.to_s)
82
+ res = self.class.get(@base_path+"/phbk_getList.aspx", query: params)
83
+ print_response res
84
+ end
85
+
86
+ # ==== Attributes
87
+ # * +page+ : Page Number (default=1)
88
+ # * +size+ : number of records per page (default=10)
89
+ # * +group+ : Group Name
90
+ #
91
+ # ==== Example
92
+ # sms.list_phone_book_by_group({
93
+ # page: 1,
94
+ # size: 10,
95
+ # group: "My Group"
96
+ # })
97
+ #
98
+ def list_phone_book_by_group(params = {})
99
+ params[:username] = @username
100
+ params[:auth] = auth(@username.to_s+@password.to_s)
101
+ res = self.class.get(@base_path+"/phbk_getListbyGroup.aspx", query: params)
102
+ print_response res
103
+ end
104
+
105
+ # ==== Attributes
106
+ # * +id+ : Contact ID Number
107
+ #
108
+ # ==== Example
109
+ # sms.contact_detail({id: 1})
110
+ #
111
+ def contact_detail(params = {})
112
+ params[:username] = @username
113
+ params[:auth] = auth(@username.to_s+@password.to_s)
114
+ res = self.class.get(@base_path+"/phbk_getCompleteData.aspx", query: params)
115
+ print_response res
116
+ end
117
+
118
+ # ==== Attributes
119
+ # * +name+ : Name to search
120
+ #
121
+ # ==== Example
122
+ # sms.find_contact({name: "John Doe"})
123
+ #
124
+ def find_contact(params = {})
125
+ params[:username] = @username
126
+ params[:auth] = auth(@username.to_s+@password.to_s)
127
+ res = self.class.get(@base_path+"/phbk_findName.aspx", query: params)
128
+ print_response res
129
+ end
130
+
131
+ # ==== Attributes
132
+ # * +number+ : Number to search
133
+ #
134
+ # ==== Example
135
+ # sms.find_number({number: "085699999999"})
136
+ #
137
+ def find_number(params = {})
138
+ params[:username] = @username
139
+ params[:auth] = auth(@username.to_s+@password.to_s)
140
+ res = self.class.get(@base_path+"/phbk_findPhNumber.aspx", query: params)
141
+ print_response res
142
+ end
143
+
144
+
145
+
146
+
147
+
148
+ end
149
+ end
@@ -1,9 +1,32 @@
1
1
  module SmsMasking
2
2
  module SendSms
3
+
4
+ # ==== Attributes
5
+ # * +mobile+ : recipient
6
+ # * +message+ : SMS
7
+ #
8
+ # ==== Example
9
+ # sms.send_sms({mobile: "085642568786", message: "your message"})
10
+ #
3
11
  def send_sms(params = {})
4
12
  params[:username] = @username
5
- params[:auth] = auth(params[:mobile])
6
- res = self.class.get("/Web2SMS/api/sendSMS.aspx", query: params)
13
+ params[:auth] = auth(@username.to_s+@password.to_s+params[:mobile])
14
+ res = self.class.get(@base_path+"/sendSMS.aspx", query: params)
15
+ print_response res
16
+ end
17
+
18
+ # ==== Attributes
19
+ # * +group+ : Group Name
20
+ # * +message+ : SMS
21
+ #
22
+ # ==== Example
23
+ # sms.send_sms_group({group: "My Group", message: "your message"})
24
+ #
25
+ def send_sms_group(params = {})
26
+ params[:username] = @username
27
+ params[:auth] = auth(@username.to_s+@password.to_s)
28
+ params[:msg] = params.delete :message
29
+ res = self.class.get(@base_path+"/SendSMSGroup.aspx", query: params)
7
30
  print_response res
8
31
  end
9
32
  end
@@ -1,3 +1,3 @@
1
1
  module SmsMasking
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sms_masking
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - yunanhelmy
@@ -87,6 +87,7 @@ files:
87
87
  - lib/sms_masking.rb
88
88
  - lib/sms_masking/auth.rb
89
89
  - lib/sms_masking/base.rb
90
+ - lib/sms_masking/phone_book.rb
90
91
  - lib/sms_masking/railtie.rb
91
92
  - lib/sms_masking/response.rb
92
93
  - lib/sms_masking/send_sms.rb