arolitec_sms 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4fbd7766ff594f9c62fed2905974848278be02d4cc42d40973a2bc3f50ff0b1a
4
+ data.tar.gz: 0bcecc0444cde400bf25cdfc147c2ddd852f7ba4d76116503cfdd3cfbab90373
5
+ SHA512:
6
+ metadata.gz: 6f8abdfb649e7cb193aca899004de53cf7a6bf308d2f492f8d49c49214bf5363ab714501d5c5d9a35975e46bace269a73d1c2e492378c87c60b890879fd3d18b
7
+ data.tar.gz: 7ff425add6fcaba4951cc983ef7065e1e8949eafe04304c16ede25d8182139ea97ed527a6f0643a44b90fb3a7e3e9f8ae6e424023cc4cc2cacb803f9042d5493
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at a.dembele@auctum.ml. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in arolitec_sms.gemspec
4
+ gemspec
@@ -0,0 +1,24 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ arolitec_sms (0.1.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ faraday (0.15.4)
10
+ multipart-post (>= 1.2, < 3)
11
+ multipart-post (2.1.1)
12
+ rake (10.5.0)
13
+
14
+ PLATFORMS
15
+ ruby
16
+
17
+ DEPENDENCIES
18
+ arolitec_sms!
19
+ bundler (~> 2.0)
20
+ faraday (~> 0.15.4)
21
+ rake (~> 10.0)
22
+
23
+ BUNDLED WITH
24
+ 2.1.2
@@ -0,0 +1,39 @@
1
+ # ArolitecSms
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/arolitec_sms`. 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 'arolitec_sms'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install arolitec_sms
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]/arolitec_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
+
37
+ ## Code of Conduct
38
+
39
+ Everyone interacting in the ArolitecSms project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/arolitec_sms/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,41 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "arolitec_sms/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "arolitec_sms"
8
+ spec.version = ArolitecSms::VERSION
9
+ spec.authors = ["thkernel"]
10
+ spec.email = ["a.dembele@auctum.ml"]
11
+
12
+ spec.summary = %q{Arolitec SMS API HTTP client.}
13
+ spec.description = %q{Ruby HTTP client to interact with Arolitec SMS Gateway.}
14
+ spec.homepage = "https://github.com/thkernel"
15
+
16
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
18
+ if spec.respond_to?(:metadata)
19
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
20
+
21
+ spec.metadata["homepage_uri"] = spec.homepage
22
+ spec.metadata["source_code_uri"] = "https://github.com/thkernel"
23
+ spec.metadata["changelog_uri"] = "https://github.com/thkernel"
24
+ else
25
+ raise "RubyGems 2.0 or newer is required to protect against " \
26
+ "public gem pushes."
27
+ end
28
+
29
+ # Specify which files should be added to the gem when it is released.
30
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
31
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
32
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
33
+ end
34
+ spec.bindir = "exe"
35
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
36
+ spec.require_paths = ["lib"]
37
+
38
+ spec.add_development_dependency "bundler", "~> 2.0"
39
+ spec.add_development_dependency 'faraday', '~> 0.15.4'
40
+ spec.add_development_dependency "rake", "~> 10.0"
41
+ end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "arolitec_sms"
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__)
@@ -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,24 @@
1
+ # Gems
2
+ require "faraday"
3
+ require "json"
4
+
5
+ require "arolitec_sms/version"
6
+ require "arolitec_sms/configuration"
7
+ require "arolitec_sms/exceptions"
8
+ #require "arolitec_sms/interceptor"
9
+ require "arolitec_sms/client"
10
+
11
+ module ArolitecSms
12
+
13
+ class << self
14
+ attr_accessor :configuration
15
+ end
16
+
17
+ def self.configuration
18
+ @configuration ||= Configuration.new
19
+ end
20
+
21
+ def self.configure
22
+ yield(configuration)
23
+ end
24
+ end
@@ -0,0 +1,74 @@
1
+ require_relative "exceptions"
2
+
3
+ module ArolitecSms
4
+ class Client
5
+
6
+ def send(sender, receiver, content)
7
+ message = {}
8
+
9
+ message[:charset] = ArolitecSms.configuration.charset
10
+ message[:flash] = ArolitecSms.configuration.flash
11
+ message[:climsgid] = Time.now.strftime("%Y%m%d%H%M%S")
12
+ message[:numericsender] = ""
13
+ message[:sender] = sender
14
+ message[:receiver] = receiver
15
+ message[:content] = content
16
+
17
+ puts "MESSAGE: #{message}"
18
+
19
+ post(ArolitecSms.configuration.send_sms_endpoint, message)
20
+
21
+ rescue => e
22
+
23
+ end
24
+
25
+
26
+ def api_configured?
27
+
28
+ api_base_url = ArolitecSms.configuration.api_base_url
29
+ send_sms_endpoint = ArolitecSms.configuration.send_sms_endpoint
30
+ api_user_name = ArolitecSms.configuration.api_user_name
31
+ api_user_password = ArolitecSms.configuration.api_user_password
32
+
33
+ if api_base_url.present? || send_sms_endpoint.present? || api_user_name.present? || api_user_password.present?
34
+ return true
35
+ else
36
+ return false
37
+ end
38
+
39
+ end
40
+
41
+ def post(endpoint, message)
42
+
43
+ if api_configured?
44
+
45
+ # Inialize a new connection.
46
+ connexion = Faraday.new(ArolitecSms.configuration.api_base_url)
47
+
48
+ payload = "?user=#{ArolitecSms.configuration.api_user_name}&password=#{ArolitecSms.configuration.api_user_password}&sender=#{message[:sender]}&receiv
49
+ er=#{message[:receiver]}&content=#{message[:content]}"
50
+
51
+ response = connexion.post do |req|
52
+ req.url(endpoint + payload)
53
+ #req.headers['Content-Type'] = 'application/json'
54
+ #req.headers['Authorization'] = 'Bearer ' + ArolitecSms.configuration.access_token
55
+ #req.body = payload.to_json
56
+ end
57
+
58
+
59
+ if response.status == 200
60
+ puts "LA REPONSE DE LA REQUETTE EST: #{response.body}"
61
+
62
+ return response
63
+
64
+ elsif response.status == 401
65
+ puts "LA REPONSE DE LA REQUETTE EST: #{response.body}"
66
+
67
+ end
68
+ else
69
+ raise ArolitecSms::ArolitecSmsConfigurationError
70
+ end
71
+ end
72
+
73
+ end
74
+ end
@@ -0,0 +1,13 @@
1
+ module ArolitecSms
2
+ class Configuration
3
+ attr_accessor :api_base_url,
4
+ :send_sms_endpoint,
5
+ :api_user_name,
6
+ :api_user_password,
7
+ :dlr_url,
8
+ :flash,
9
+ :charset
10
+
11
+
12
+ end
13
+ end
@@ -0,0 +1,9 @@
1
+ module ArolitecSms
2
+ class ArolitecSmsError < StandardError
3
+ end
4
+ class ArolitecSmsConfigurationError < ArolitecSmsError
5
+ def initialize(msg="Erreur de configuration de l'API")
6
+ super
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,58 @@
1
+
2
+ module ArolitecSms
3
+ module HttpInterceptor
4
+
5
+
6
+ def api_configured?
7
+
8
+ api_base_url = ArolitecSms.configuration.api_base_url
9
+ send_sms_endpoint = ArolitecSms.configuration.send_sms_endpoint
10
+ api_user_name = ArolitecSms.configuration.api_user_name
11
+ api_user_password = ArolitecSms.configuration.api_user_password
12
+
13
+ if api_base_url.present? && send_sms_endpoint.present? && api_user_name.present? && api_user_password.present?
14
+ return true
15
+ else
16
+ return false
17
+ end
18
+
19
+ end
20
+
21
+
22
+ def post(endpoint, message)
23
+
24
+ if api_configured?
25
+
26
+ # Inialize a new connection.
27
+ conn = Faraday.new(ArolitecSms.configuration.api_base_url)
28
+
29
+ payload = "?user=#{ArolitecSms.configuration.api_user_name}&password=#{ArolitecSms.configuration.api_user_password}&sender=#{message[:sender]}&receiv
30
+ er=#{message[:receiver]}&content=#{message[:content]}"
31
+
32
+ response = conn.post do |req|
33
+ req.url endpoint + payload
34
+ #req.headers['Content-Type'] = 'application/json'
35
+ #req.headers['Authorization'] = 'Bearer ' + ArolitecSms.configuration.access_token
36
+ #req.body = payload.to_json
37
+ end
38
+
39
+
40
+ if response.status == 200
41
+ puts "LA REPONSE DE LA REQUETTE EST: #{response.body}"
42
+
43
+ return response
44
+
45
+ elsif response.status == 401
46
+ puts "LA REPONSE DE LA REQUETTE EST: #{response.body}"
47
+
48
+ end
49
+ else
50
+ render text: "Invalid API Base!"
51
+ end
52
+ end
53
+
54
+
55
+
56
+
57
+ end
58
+ end
@@ -0,0 +1,3 @@
1
+ module ArolitecSms
2
+ VERSION = "0.1.1"
3
+ end
metadata ADDED
@@ -0,0 +1,103 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: arolitec_sms
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - thkernel
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-04-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: faraday
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.15.4
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.15.4
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: Ruby HTTP client to interact with Arolitec SMS Gateway.
56
+ email:
57
+ - a.dembele@auctum.ml
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - CODE_OF_CONDUCT.md
64
+ - Gemfile
65
+ - Gemfile.lock
66
+ - README.md
67
+ - Rakefile
68
+ - arolitec_sms.gemspec
69
+ - bin/console
70
+ - bin/setup
71
+ - lib/arolitec_sms.rb
72
+ - lib/arolitec_sms/client.rb
73
+ - lib/arolitec_sms/configuration.rb
74
+ - lib/arolitec_sms/exceptions.rb
75
+ - lib/arolitec_sms/interceptor.rb
76
+ - lib/arolitec_sms/version.rb
77
+ homepage: https://github.com/thkernel
78
+ licenses: []
79
+ metadata:
80
+ allowed_push_host: https://rubygems.org
81
+ homepage_uri: https://github.com/thkernel
82
+ source_code_uri: https://github.com/thkernel
83
+ changelog_uri: https://github.com/thkernel
84
+ post_install_message:
85
+ rdoc_options: []
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ requirements: []
99
+ rubygems_version: 3.1.2
100
+ signing_key:
101
+ specification_version: 4
102
+ summary: Arolitec SMS API HTTP client.
103
+ test_files: []