cequens 0.0.2 → 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 +20 -2
- data/cequens.gemspec +2 -2
- data/lib/cequens.rb +7 -1
- 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
- data/lib/generators/cequens/config_generator.rb +1 -1
- data/lib/generators/cequens/templates/cequens_config.rb +5 -0
- metadata +7 -5
- data/lib/generators/cequens/templates/cequens_template.rb +0 -5
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
|
|
@@ -22,6 +22,15 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
+
configure access token as:
|
26
|
+
|
27
|
+
$ rails g cequens:config
|
28
|
+
|
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
|
32
|
+
end
|
33
|
+
|
25
34
|
### Send SMS
|
26
35
|
|
27
36
|
```ruby
|
@@ -38,3 +47,12 @@ res = Cequens.send_sms(params)
|
|
38
47
|
res.success? # => true
|
39
48
|
```
|
40
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/cequens.gemspec
CHANGED
@@ -13,8 +13,8 @@ Gem::Specification.new do |spec|
|
|
13
13
|
spec.summary = 'A library to interface with Cequens SMS gateway API.'
|
14
14
|
spec.license = 'MIT'
|
15
15
|
|
16
|
-
spec.metadata['homepage_uri'] = 'https://github.com/
|
17
|
-
spec.metadata['source_code_uri'] = 'https://github.com/
|
16
|
+
spec.metadata['homepage_uri'] = 'https://github.com/AhmedAliIbrahim/cequens'
|
17
|
+
spec.metadata['source_code_uri'] = 'https://github.com/AhmedAliIbrahim/cequens'
|
18
18
|
|
19
19
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
20
20
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
data/lib/cequens.rb
CHANGED
@@ -7,8 +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 '
|
10
|
+
require 'cequens/requests/get_sms_details_request'
|
11
|
+
require 'cequens/contracts/get_sms_details_contract'
|
11
12
|
require 'rails'
|
13
|
+
require 'byebug'
|
12
14
|
|
13
15
|
module Cequens
|
14
16
|
class << self
|
@@ -21,5 +23,9 @@ module Cequens
|
|
21
23
|
def send_sms(params, opts = {})
|
22
24
|
Request.new('send_sms', params, opts).fire_request
|
23
25
|
end
|
26
|
+
|
27
|
+
def get_sms_details(params, opts = {})
|
28
|
+
Request.new('get_sms_details', params, opts).fire_request
|
29
|
+
end
|
24
30
|
end
|
25
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,20 +171,22 @@ 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
|
180
182
|
- lib/generators/cequens/config_generator.rb
|
181
|
-
- lib/generators/cequens/templates/
|
183
|
+
- lib/generators/cequens/templates/cequens_config.rb
|
182
184
|
homepage:
|
183
185
|
licenses:
|
184
186
|
- MIT
|
185
187
|
metadata:
|
186
|
-
homepage_uri: https://github.com/
|
187
|
-
source_code_uri: https://github.com/
|
188
|
+
homepage_uri: https://github.com/AhmedAliIbrahim/cequens
|
189
|
+
source_code_uri: https://github.com/AhmedAliIbrahim/cequens
|
188
190
|
post_install_message:
|
189
191
|
rdoc_options: []
|
190
192
|
require_paths:
|