cequens 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +16 -5
- data/lib/cequens.rb +7 -0
- data/lib/cequens/connection.rb +5 -3
- data/lib/cequens/contracts/get_sms_details_contract.rb +13 -0
- data/lib/cequens/request.rb +4 -0
- data/lib/cequens/requests/get_sms_details_request.rb +40 -0
- data/lib/cequens/requests/send_sms_request.rb +1 -1
- data/lib/cequens/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f11166fbdbe9870dc4ca38824b06c4bf8f508b9949f8722fe92cad32d527b25e
|
4
|
+
data.tar.gz: c6b5eb0a9c544b27922643e42fa87d864614ea2d5d5cd0593f687080980e3d13
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8588a8033b78e4bbe046297c18bf56c0d399b0603e918ea3d9ff21b0ee4669fbb73d4b5cfca862ceda6c6c2f11f39f512a0126c48b377efe629aecc93fb699e8
|
7
|
+
data.tar.gz: 6feb98cdd452e20c471bd8cbec09161defe58bdc2d66238a9847064af5b9f5aa61645a3daca27bba61c71ad255cffc34437fb7d40e5565cf00475b3dbc19dac9
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# Cequens
|
2
2
|
|
3
|
-
**Disclaimer:** we are not officially affilated with
|
3
|
+
**Disclaimer:** we are not officially affilated with Cequens company.
|
4
4
|
|
5
|
-
A plug-and-play library that make it easier to use
|
5
|
+
A plug-and-play library that make it easier to use Cequens SMS APIs
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
@@ -24,10 +24,11 @@ Or install it yourself as:
|
|
24
24
|
|
25
25
|
configure access token as:
|
26
26
|
|
27
|
-
$ rails g cequens
|
27
|
+
$ rails g cequens:config
|
28
28
|
|
29
|
-
Cequens.
|
30
|
-
#
|
29
|
+
Cequens.config do |c|
|
30
|
+
# c.access_token = token # add your access token not api token
|
31
|
+
# access_token is what you get when you login
|
31
32
|
end
|
32
33
|
|
33
34
|
### Send SMS
|
@@ -45,3 +46,13 @@ res = Cequens.send_sms(params)
|
|
45
46
|
|
46
47
|
res.success? # => true
|
47
48
|
```
|
49
|
+
|
50
|
+
### Get SMS Details
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
res = Cequens.get_sms_details(id: "AAAAA")
|
54
|
+
# => #<Cequens::Response:0x00007ffd672b29f8 @api_response={"replyCode"=>0, "replyMessage"=>"Request handled successfully", "requestId"=>"64035880-7044-11eb-9f04-11a5522e89a7", "clientRequestId"=>0, "requestTime"=>"2021-02-16T10:47:40.296", "data"=>{"SentSMSIDs"=>[{"SMSId"=>"056ef72a-1497-47be-a4c8-4a7835e071dc"}], "InvalidRecipients"=>""}}>
|
55
|
+
|
56
|
+
res.success? # => true
|
57
|
+
res.message # => Request handled successfully
|
58
|
+
```
|
data/lib/cequens.rb
CHANGED
@@ -7,7 +7,10 @@ require 'cequens/request'
|
|
7
7
|
require 'cequens/response'
|
8
8
|
require 'cequens/requests/send_sms_request'
|
9
9
|
require 'cequens/contracts/send_sms_contract'
|
10
|
+
require 'cequens/requests/get_sms_details_request'
|
11
|
+
require 'cequens/contracts/get_sms_details_contract'
|
10
12
|
require 'rails'
|
13
|
+
require 'byebug'
|
11
14
|
|
12
15
|
module Cequens
|
13
16
|
class << self
|
@@ -20,5 +23,9 @@ module Cequens
|
|
20
23
|
def send_sms(params, opts = {})
|
21
24
|
Request.new('send_sms', params, opts).fire_request
|
22
25
|
end
|
26
|
+
|
27
|
+
def get_sms_details(params, opts = {})
|
28
|
+
Request.new('get_sms_details', params, opts).fire_request
|
29
|
+
end
|
23
30
|
end
|
24
31
|
end
|
data/lib/cequens/connection.rb
CHANGED
@@ -8,10 +8,12 @@ module Cequens
|
|
8
8
|
CEQUENS_BASE_URL = 'https://apis.cequens.com/'
|
9
9
|
|
10
10
|
class << self
|
11
|
-
def
|
12
|
-
|
11
|
+
def get(path, _params, _body, _options)
|
12
|
+
connection.get(path)
|
13
|
+
end
|
13
14
|
|
14
|
-
|
15
|
+
def post(path, params, body, _options)
|
16
|
+
connection.post(path) do |request|
|
15
17
|
request.params = params
|
16
18
|
request.body = body.to_json
|
17
19
|
end
|
data/lib/cequens/request.rb
CHANGED
@@ -22,6 +22,10 @@ module Cequens
|
|
22
22
|
self.class.include Requests::SendSMSRequest
|
23
23
|
validate_params!
|
24
24
|
@request = build_send_sms_request
|
25
|
+
when 'get_sms_details'
|
26
|
+
self.class.include Requests::GetSMSDetailsRequest
|
27
|
+
validate_params!
|
28
|
+
@request = build_get_sms_details_request
|
25
29
|
end
|
26
30
|
end
|
27
31
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cequens
|
4
|
+
module Requests
|
5
|
+
module GetSMSDetailsRequest
|
6
|
+
DEFAULTS = {}.freeze
|
7
|
+
|
8
|
+
def fire_request
|
9
|
+
cequens_api_response = Connection.get(request[:path], request[:params], request[:body], request[:options])
|
10
|
+
response_body = JSON.parse(cequens_api_response.body)
|
11
|
+
|
12
|
+
Response.new(response_body)
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def build_get_sms_details_request
|
18
|
+
{
|
19
|
+
path: "sms/v1/messages/#{message_id}",
|
20
|
+
params: {},
|
21
|
+
body: {},
|
22
|
+
options: options
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
def request_params
|
27
|
+
@request_params ||= DEFAULTS.merge(params)
|
28
|
+
end
|
29
|
+
|
30
|
+
def message_id
|
31
|
+
request_params[:id]
|
32
|
+
end
|
33
|
+
|
34
|
+
def validate_params!
|
35
|
+
contract = Contracts::GetSMSDetailsContract.new.call(request_params)
|
36
|
+
raise InvalidCequensRequestError, contract.errors.to_h if contract.failure?
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/cequens/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cequens
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ahmed Ali
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-02-
|
11
|
+
date: 2021-02-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-validation
|
@@ -171,9 +171,11 @@ files:
|
|
171
171
|
- cequens.gemspec
|
172
172
|
- lib/cequens.rb
|
173
173
|
- lib/cequens/connection.rb
|
174
|
+
- lib/cequens/contracts/get_sms_details_contract.rb
|
174
175
|
- lib/cequens/contracts/send_sms_contract.rb
|
175
176
|
- lib/cequens/errors.rb
|
176
177
|
- lib/cequens/request.rb
|
178
|
+
- lib/cequens/requests/get_sms_details_request.rb
|
177
179
|
- lib/cequens/requests/send_sms_request.rb
|
178
180
|
- lib/cequens/response.rb
|
179
181
|
- lib/cequens/version.rb
|