comtele_sdk 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 422a4f7bfe76680b325265cb42123f2872187069c5008ca8be1bbc3d5177ae4d
4
+ data.tar.gz: 5b34604d6bb5126bc5e0a53f3bfea165a787013804c194754355b7c46b24af8e
5
+ SHA512:
6
+ metadata.gz: 132ab0f9510a584e7e79729ab1836c47bcd985a048eb7666239eb546ce7eee1bd0ce69cd6e86bcd9b0ba898e3ba8bfb150299aa8537766de157d1ae2bc725ea6
7
+ data.tar.gz: caccde6da7aa568dc80d5ba33aa890d660e74ecc3a12e5d63cd7c23c1f0a92038810619071d1619923a16a2d433fe5c9c182219ff51eefb403840227f9075aed
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in comtele_sdk.gemspec
6
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Diego Vieira
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # ComteleSdk
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/comtele_sdk`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'comtele_sdk'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install comtele_sdk
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/comtele_sdk.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "comtele_sdk"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,28 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "comtele_sdk/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "comtele_sdk"
8
+ spec.version = ComteleSdk::VERSION
9
+ spec.authors = ["Diego Vieira"]
10
+ spec.email = ["desenvolvimento@comtele.com.br"]
11
+
12
+ spec.summary = %q{SDK para envio de mensagens de texto usando a plataforma Comtele (Ruby)}
13
+ spec.homepage = "https://docs.comtele.com.br"
14
+ spec.license = "MIT"
15
+
16
+ # Specify which files should be added to the gem when it is released.
17
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
18
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
19
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
+ end
21
+ spec.bindir = "exe"
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
+ spec.require_paths = ["lib"]
24
+
25
+ spec.add_dependency "rest-client"
26
+ spec.add_development_dependency "bundler", "~> 1.16"
27
+ spec.add_development_dependency "rake", "~> 10.0"
28
+ end
@@ -0,0 +1,3 @@
1
+ module ComteleSdk
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,205 @@
1
+ require "comtele_sdk/version"
2
+ require 'rest-client'
3
+ require 'json'
4
+
5
+ module ComteleSdk
6
+ class AccountService
7
+
8
+ def initialize(api_key)
9
+ @api_key = api_key
10
+ @base_address = 'https://sms.comtele.com.br/api/v2'
11
+ @headers = {
12
+ 'Accept': 'application/json',
13
+ 'Content-type': 'application/json',
14
+ 'auth-key': @api_key
15
+ }
16
+ end
17
+
18
+ def get_account_by_username(username)
19
+ url = @base_address + '/accounts/' + username
20
+ response = RestClient.get(url, @headers)
21
+
22
+ return JSON.parse(response)
23
+ end
24
+
25
+ def get_all_accounts
26
+ url = @base_address + '/accounts'
27
+ response = RestClient.get(url, @headers)
28
+
29
+ return JSON.parse(response)
30
+ end
31
+ end
32
+
33
+ class ContextMessageService
34
+ def initialize(api_key)
35
+ @api_key = api_key
36
+ @base_address = 'https://sms.comtele.com.br/api/v2'
37
+ @headers = {
38
+ 'Accept': 'application/json',
39
+ 'Content-type': 'application/json',
40
+ 'auth-key': @api_key
41
+ }
42
+ end
43
+
44
+ def send(sender, context_rule_name, receivers)
45
+ url = @base_address + '/sendcontextmessage'
46
+
47
+ payload = JSON.generate({
48
+ 'sender': sender,
49
+ 'contextRuleName': context_rule_name,
50
+ 'receivers': receivers.join(',')
51
+ })
52
+
53
+ response = RestClient.post(url, payload, @headers)
54
+
55
+ return JSON.parse(response)
56
+ end
57
+
58
+ def schedule(sender, context_rule_name, schedule_date, receivers)
59
+ url = @base_address + '/schedulecontextmessage'
60
+
61
+ payload = JSON.generate({
62
+ 'sender': sender,
63
+ 'contextRuleName': context_rule_name,
64
+ 'scheduleDate': schedule_date,
65
+ 'receivers': receivers.join(',')
66
+ })
67
+
68
+ response = RestClient.post(url, payload, @headers)
69
+
70
+ return JSON.parse(response)
71
+ end
72
+
73
+ def get_report(start_date, end_date, sender = '', context_rule_name = '')
74
+ url = @base_address + '/contextreporting?startDate=' + start_date + '&endDate=' + end_date + '&sender=' + sender + '&contextRuleName=' + context_rule_name
75
+ response = RestClient.get(url, @headers)
76
+
77
+ return JSON.parse(response)
78
+ end
79
+ end
80
+
81
+ class CreditService
82
+ def initialize(api_key)
83
+ @api_key = api_key
84
+ @base_address = 'https://sms.comtele.com.br/api/v2'
85
+ @headers = {
86
+ 'Accept': 'application/json',
87
+ 'Content-Type': 'application/json',
88
+ 'auth-key': @api_key
89
+ }
90
+ end
91
+
92
+ def get_credits(username)
93
+ url = @base_address + '/credits/' + username
94
+ response = RestClient.get(url, @headers)
95
+
96
+ return JSON.parse(response)
97
+ end
98
+
99
+ def get_my_credits
100
+ url = @base_address + '/credits'
101
+ response = RestClient.get(url, @headers)
102
+
103
+ return JSON.parse(response)
104
+ end
105
+
106
+ def get_history(username)
107
+ url = @base_address + '/balancehistory/' + username
108
+ response = RestClient.get(url, @headers)
109
+
110
+ return JSON.parse(response)
111
+ end
112
+
113
+ def add_credits(username, amount)
114
+ url = @base_address + '/credits/'+ username + '?amount=' + amount.to_s
115
+ response = RestClient.put(url, {}, @headers)
116
+
117
+ return JSON.parse(response)
118
+ end
119
+ end
120
+
121
+ class DeliveryStatus
122
+ ALL = 'all'
123
+ DELIVERED = 'true'
124
+ UNDELIVERED = 'false'
125
+ end
126
+
127
+ class ReplyService
128
+ def initialize(api_key)
129
+ @api_key = api_key
130
+ @base_address = 'https://sms.comtele.com.br/api/v2'
131
+ @headers = {
132
+ 'Accept': 'application/json',
133
+ 'Content-type': 'application/json',
134
+ 'auth-key': @api_key
135
+ }
136
+ end
137
+
138
+ def get_report(start_date, end_date, sender = '')
139
+ url = @base_address + '/replyreporting?startDate=' + start_date + '&endDate=' + end_date + '&sender=' + sender
140
+ response = RestClient.get(url, @headers)
141
+
142
+ return JSON.parse(response)
143
+ end
144
+ end
145
+
146
+ class ReportGroupType
147
+ MONTHLY = 'true'
148
+ DAILY = 'false'
149
+ end
150
+
151
+ class TextMessageService
152
+ def initialize(api_key)
153
+ @api_key = api_key
154
+ @base_address = 'https://sms.comtele.com.br/api/v2'
155
+ @headers = {
156
+ 'Accept': 'application/json',
157
+ 'Content-type': 'application/json',
158
+ 'auth-key': @api_key
159
+ }
160
+ end
161
+
162
+ def send(sender, content, receivers)
163
+ url = @base_address + '/send'
164
+
165
+ payload = JSON.generate({
166
+ 'sender': sender,
167
+ 'content': content,
168
+ 'receivers': receivers.join(',')
169
+ })
170
+
171
+ response = RestClient.post(url, payload, @headers)
172
+
173
+ return JSON.parse(response)
174
+ end
175
+
176
+ def schedule(sender, content, schedule_date, receivers)
177
+ url = @base_address + '/schedule'
178
+
179
+ payload = JSON.generate({
180
+ 'sender': sender,
181
+ 'content': content,
182
+ 'scheduleDate': schedule_date,
183
+ 'receivers': receivers.join(',')
184
+ })
185
+
186
+ response = RestClient.post(url, payload, @headers)
187
+
188
+ return JSON.parse(response)
189
+ end
190
+
191
+ def get_detailed_report(start_date, end_date, delivery_status)
192
+ url = @base_address + '/detailedreporting?startDate=' + start_date + '&endDate=' + end_date + '&delivered=' + delivery_status
193
+ response = RestClient.get(url, @headers)
194
+
195
+ return JSON.parse(response)
196
+ end
197
+
198
+ def get_consolidated_report(start_date, end_date, group_type)
199
+ url = @base_address + '/consolidatedreporting?startDate=' + start_date + '&endDate=' + end_date + '&group=' + group_type
200
+ response = RestClient.get(url, @headers)
201
+
202
+ return JSON.parse(response)
203
+ end
204
+ end
205
+ end
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: comtele_sdk
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Diego Vieira
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-06-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rest-client
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.16'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.16'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ description:
56
+ email:
57
+ - desenvolvimento@comtele.com.br
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - bin/console
68
+ - bin/setup
69
+ - comtele_sdk.gemspec
70
+ - lib/comtele_sdk.rb
71
+ - lib/comtele_sdk/version.rb
72
+ homepage: https://docs.comtele.com.br
73
+ licenses:
74
+ - MIT
75
+ metadata: {}
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirements: []
91
+ rubyforge_project:
92
+ rubygems_version: 2.7.6
93
+ signing_key:
94
+ specification_version: 4
95
+ summary: SDK para envio de mensagens de texto usando a plataforma Comtele (Ruby)
96
+ test_files: []