semaphore-sms 0.1.2 → 0.1.3
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 +4 -4
- data/README.md +137 -5
- data/lib/generators/templates/semaphore-sms.rb +1 -1
- data/lib/semaphore/sms/client.rb +1 -1
- data/lib/semaphore/sms/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7358f54b837825b64dd4bc1b141e17b18cce880
|
4
|
+
data.tar.gz: 61e9d78419c12c8a810eeed68b3bf7cc9d3c1aa1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5bb7f0a88a10d185a709097e5574320458f4ccfc0cd417de2c0b1e9647de60dc10c2c862e8c6821a487390ce2a663c06aa9325c7e45d11f328ac3f8428f6974d
|
7
|
+
data.tar.gz: 84c048da5047661a273e35b8a6ada3c84621bdfe34032ac263b555091ea66b360ad2f4a80b73c6f4f23bf9264b57f6fc930a92ebc4a6b5b61308c23394013a6b
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# Semaphore::Sms
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
This is a ruby api wrapper for Semaphore, https://semaphore.co/
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
@@ -22,7 +20,141 @@ Or install it yourself as:
|
|
22
20
|
|
23
21
|
## Usage
|
24
22
|
|
25
|
-
|
23
|
+
Run:
|
24
|
+
```
|
25
|
+
rails g semaphore:sms:install
|
26
|
+
```
|
27
|
+
|
28
|
+
Note:
|
29
|
+
|
30
|
+
This will generate a file in `config/initializers` called `semaphore-sms.rb`. Configure semaphore api here.
|
31
|
+
|
32
|
+
```
|
33
|
+
Semaphore::Sms.setup do |config|
|
34
|
+
# config.api_key = "YOUR API KEY HERE"
|
35
|
+
# NOTE: add if you want to use a single sender name by default.
|
36
|
+
# config.sender_name = "SEMAPHORE"
|
37
|
+
end
|
38
|
+
```
|
39
|
+
Below we demonstrate the most basic usage of the library:
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
require "semaphore-sms"
|
43
|
+
|
44
|
+
# You should already configure you api key under `initializers/semaphore-sms.rb`
|
45
|
+
client = Semaphore::Sms.client
|
46
|
+
|
47
|
+
# Sending a single message.
|
48
|
+
|
49
|
+
client.send("Hello World", "09175488888")
|
50
|
+
|
51
|
+
# response
|
52
|
+
|
53
|
+
[
|
54
|
+
{
|
55
|
+
"message_id" => 55871500,
|
56
|
+
"user_id" => 4788,
|
57
|
+
"user" => "jag.arnold.go@gmail.com",
|
58
|
+
"account_id" => 4688,
|
59
|
+
"account" => "FreeLance",
|
60
|
+
"recipient" => "639778048888",
|
61
|
+
"message" => "Hello World",
|
62
|
+
"sender_name" => "Semaphore",
|
63
|
+
"network" => "Next",
|
64
|
+
"status" => "Pending",
|
65
|
+
"type" => "Single",
|
66
|
+
"source" => "Api",
|
67
|
+
"created_at" => "2018-03-12 20:11:21",
|
68
|
+
"updated_at" => "2018-03-12 20:11:21"
|
69
|
+
}
|
70
|
+
]
|
71
|
+
|
72
|
+
# Sending a single message to multiple recipients or bulk messages.
|
73
|
+
|
74
|
+
client.send("Hello World", ["09175488888","09778048888"])
|
75
|
+
|
76
|
+
# response
|
77
|
+
|
78
|
+
[
|
79
|
+
{
|
80
|
+
"message_id" => 55871554,
|
81
|
+
"user_id" => 4788,
|
82
|
+
"user" => "jag.arnold.go@gmail.com",
|
83
|
+
"account_id" => 4688,
|
84
|
+
"account" => "FreeLance",
|
85
|
+
"recipient" => "639175488888",
|
86
|
+
"message" => "Hello World",
|
87
|
+
"sender_name" => "Semaphore",
|
88
|
+
"network" => "Globe",
|
89
|
+
"status" => "Pending",
|
90
|
+
"type" => "Bulk",
|
91
|
+
"source" => "Api",
|
92
|
+
"created_at" => "2018-03-12 20:16:46",
|
93
|
+
"updated_at" => "2018-03-12 20:16:46"
|
94
|
+
},
|
95
|
+
{
|
96
|
+
"message_id" => 55871555,
|
97
|
+
"user_id" => 4788,
|
98
|
+
"user" => "jag.arnold.go@gmail.com",
|
99
|
+
"account_id" => 4688,
|
100
|
+
"account" => "FreeLance",
|
101
|
+
"recipient" => "639778048888",
|
102
|
+
"message" => "Hello World",
|
103
|
+
"sender_name" => "Semaphore",
|
104
|
+
"network" => "Next",
|
105
|
+
"status" => "Pending",
|
106
|
+
"type" => "Bulk",
|
107
|
+
"source" => "Api",
|
108
|
+
"created_at" => "2018-03-12 20:16:46",
|
109
|
+
"updated_at" => "2018-03-12 20:16:46"
|
110
|
+
}
|
111
|
+
]
|
112
|
+
|
113
|
+
|
114
|
+
# Sending a message using a sender name.
|
115
|
+
|
116
|
+
client.send("Hello World", ["09175488888", "09175488888"], "SAITAMA")
|
117
|
+
|
118
|
+
NOTE: By default you can configure your sender name in `config/initializers/semaphore-sms` or
|
119
|
+
pass a third agument to overwrite existing sender name in `initializers/semaphore-sms.rb`.
|
120
|
+
If no sendername is attached it will default to `Semaphore`.
|
121
|
+
|
122
|
+
|
123
|
+
## Sending a single priority message.
|
124
|
+
|
125
|
+
client.priority("Hello World", "09175488888")
|
126
|
+
|
127
|
+
## Sending a single priority message to multiple recipients or bulk messages.
|
128
|
+
|
129
|
+
client.priority("Hello World", ["09175488888","09778048888"])
|
130
|
+
|
131
|
+
## Requesting for account information
|
132
|
+
|
133
|
+
client.account
|
134
|
+
|
135
|
+
## Requesting for all the messages sent
|
136
|
+
|
137
|
+
client.messages
|
138
|
+
|
139
|
+
## Requesting for a specific message
|
140
|
+
|
141
|
+
client.messages(id: 55871555)
|
142
|
+
|
143
|
+
## Requesting for all transaction made
|
144
|
+
|
145
|
+
client.transactions
|
146
|
+
client.transactions(id: 1, limit: 100) # Page and Limit are optional. Limit default to 100.
|
147
|
+
|
148
|
+
## Requesting for all sender names
|
149
|
+
|
150
|
+
client.sender_names
|
151
|
+
client.sender_name(id: 1, limit: 100) # Page and Limit are optional. Limit default to 100.
|
152
|
+
|
153
|
+
## Requesting for all users
|
154
|
+
|
155
|
+
client.users
|
156
|
+
client.users(id: 1, limit: 100) # Page and Limit are optional. Limit default to 100.
|
157
|
+
```
|
26
158
|
|
27
159
|
## Development
|
28
160
|
|
@@ -32,7 +164,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
32
164
|
|
33
165
|
## Contributing
|
34
166
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
167
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/goldendragon1988/semaphore-sms. 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.
|
36
168
|
|
37
169
|
## License
|
38
170
|
|
data/lib/semaphore/sms/client.rb
CHANGED
@@ -10,7 +10,7 @@ module Semaphore
|
|
10
10
|
Response = Struct.new(:status, :content)
|
11
11
|
|
12
12
|
def initialize(config)
|
13
|
-
raise Semaphore::Sms::Error, 'Config must have
|
13
|
+
raise Semaphore::Sms::Error, 'Config must have api key credentials' unless config.respond_to? :api_key
|
14
14
|
@config = config
|
15
15
|
end
|
16
16
|
|