clxsms 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 35d718dbf274590f881828d08bc206bf9e7f3b53
4
+ data.tar.gz: 217ba2ad7c168efd3ad6c80cf45d464ab3d02a50
5
+ SHA512:
6
+ metadata.gz: adf30b51f2e5fbb369781f87d181cf1b40039afd64d60ea30004f33f1e26287b4fbcb24aeafe803cc1b5feb925f6950c2e03a4e46a1337a89b33a4dd3586283b
7
+ data.tar.gz: 9bc94fe72624652fad06ddc4568dee2adef583d3d9351f55d53d2b2a23279f630a5b1d3a2ae397d3b81ce46549d5e940468e7bfa1612ffdcb7fad747284f51bf
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.0
4
+ before_install: gem install bundler -v 1.10.6
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in clxsms.gemspec
4
+ gemspec
@@ -0,0 +1,33 @@
1
+ # Clxsms
2
+ By [Standout](http://standout.se/).
3
+
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'clxsms'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install clxsms
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Development
26
+
27
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
28
+
29
+
30
+ ## Contributing
31
+
32
+ Bug reports and pull requests are welcome. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
33
+
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "clxsms"
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
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'clxsms/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "clxsms"
8
+ spec.version = Clxsms::VERSION
9
+ spec.authors = ["Hüseyin Öztürk"]
10
+ spec.email = ["support@standout.se"]
11
+
12
+ spec.summary = "API wrapper for Clxnetworks's SMS service"
13
+ spec.description = "API wrapper for Clxnetworks's SMS service"
14
+ spec.homepage = "https://bitbucket.org/standoutab/clxsms"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "rest-client", '~> 1.8'
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.10"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "rspec"
26
+ end
@@ -0,0 +1,23 @@
1
+ require 'clxsms/error'
2
+ require 'clxsms/configuration'
3
+ require 'clxsms/api'
4
+ require 'clxsms/client'
5
+ require 'clxsms/version'
6
+ require 'rest-client'
7
+
8
+ module Clxsms
9
+ extend Configuration
10
+ # Alias
11
+ def self.client(options={})
12
+ Clxsms::Client.new(options)
13
+ end
14
+
15
+ def self.method_missing(method, *args, &block)
16
+ return super unless client.respond_to?(method)
17
+ client.send(method, *args, &block)
18
+ end
19
+
20
+ def self.respond_to?(method, include_private = false)
21
+ client.respond_to?(method, include_private) || super(method, include_private)
22
+ end
23
+ end
@@ -0,0 +1,18 @@
1
+ require 'clxsms/connection'
2
+ require 'clxsms/request'
3
+
4
+ module Clxsms
5
+ class API
6
+ attr_accessor *Configuration::VALID_OPTIONS_KEYS
7
+
8
+ def initialize(options={})
9
+ options = Clxsms.options.merge(options)
10
+ Configuration::VALID_OPTIONS_KEYS.each do |key|
11
+ send("#{key}=", options[key])
12
+ end
13
+ end
14
+
15
+ include Connection
16
+ include Request
17
+ end
18
+ end
@@ -0,0 +1,7 @@
1
+ module Clxsms
2
+ class Client < API
3
+ require 'clxsms/client/sendsms'
4
+
5
+ include Clxsms::Client::Sendsms
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ module Clxsms
2
+ class Client
3
+ module Sendsms
4
+ def send_sms(options={})
5
+ response = get('sendsms', options)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,72 @@
1
+ require 'clxsms/connection'
2
+ require 'clxsms/request'
3
+ require 'clxsms/version'
4
+
5
+ module Clxsms
6
+ module Configuration
7
+ VALID_OPTIONS_KEYS = [
8
+ :username,
9
+ :password,
10
+ :ssl_enabled,
11
+ :user_agent,
12
+ :dlr_url,
13
+ :dlr_mask,
14
+ :from
15
+ ].freeze
16
+
17
+ SSL_ENABLED = false
18
+
19
+ DEFAULT_USERNAME = nil
20
+
21
+ DEFAULT_PASSWORD = nil
22
+
23
+ HTTPS_HOST = "https://sms1.clxnetworks.net:3801"
24
+
25
+ HTTP_HOST = "http://sms1.clxnetworks.net:3800"
26
+
27
+ DEFAULT_USER_AGENT = "Clxsms Ruby Client/#{Clxsms::VERSION}".freeze
28
+
29
+ DEFAULT_DLR_URL = "http://localhost/"
30
+ DEFAULT_DLR_MASK = 7
31
+
32
+ DEFAULT_FROM = "0"
33
+
34
+
35
+ attr_accessor *VALID_OPTIONS_KEYS
36
+ attr_reader :http_host, :https_host
37
+
38
+ def self.extended(base)
39
+ base.reset
40
+ end
41
+
42
+ def configure
43
+ yield self
44
+ end
45
+
46
+ def options
47
+ options = {}
48
+ VALID_OPTIONS_KEYS.each { |k| options[k] = send(k) }
49
+ options
50
+ end
51
+
52
+ def http_host
53
+ HTTP_HOST
54
+ end
55
+
56
+ def https_host
57
+ HTTPS_HOST
58
+ end
59
+
60
+ # Reset to defaults
61
+ def reset
62
+ self.username = DEFAULT_USERNAME
63
+ self.password = DEFAULT_PASSWORD
64
+ self.ssl_enabled = SSL_ENABLED
65
+ self.user_agent = DEFAULT_USER_AGENT
66
+ self.dlr_url = DEFAULT_DLR_URL
67
+ self.dlr_mask = DEFAULT_DLR_MASK
68
+ self.from = DEFAULT_FROM
69
+ self
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,41 @@
1
+ require 'clxsms/connection'
2
+ require 'clxsms/request'
3
+ require 'rest-client'
4
+
5
+ module Clxsms
6
+ module Connection
7
+ private
8
+
9
+ def connection(path, params={})
10
+ host = Clxsms.ssl_enabled == true ? Clxsms.https_host : Clxsms.http_host
11
+ params.merge!({ 'dlr-mask': Clxsms.dlr_mask, 'dlr-url': Clxsms.dlr_url }) if params[:delivery_report] == true
12
+ params.delete :delivery_report
13
+
14
+ resource = RestClient::Resource.new(
15
+ host,
16
+ :headers => {
17
+ :content_type => "text/plain",
18
+ :timeout => 5,
19
+ :open_timeout => 5,
20
+ :user_agent => Clxsms.user_agent,
21
+ }
22
+ )
23
+
24
+ resource[path].get(
25
+ params: params.merge(
26
+ {
27
+ username: Clxsms.username,
28
+ password: Clxsms.password,
29
+ }
30
+ )
31
+ ){ |response, request, result, &block|
32
+ case response.code
33
+ when 202
34
+ { success: true, message: response }
35
+ else
36
+ { success: false, message: response }
37
+ end
38
+ }
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,2 @@
1
+ module Clxsms
2
+ end
@@ -0,0 +1,10 @@
1
+ require 'clxsms/connection'
2
+ require 'clxsms/request'
3
+
4
+ module Clxsms
5
+ module Request
6
+ def get(path, query={})
7
+ connection(path, query)
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,3 @@
1
+ module Clxsms
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: clxsms
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Hüseyin Öztürk
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-05-15 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: '1.8'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.8'
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.10'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.10'
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
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: API wrapper for Clxnetworks's SMS service
70
+ email:
71
+ - support@standout.se
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - ".travis.yml"
79
+ - CODE_OF_CONDUCT.md
80
+ - Gemfile
81
+ - README.md
82
+ - Rakefile
83
+ - bin/console
84
+ - bin/setup
85
+ - clxsms.gemspec
86
+ - lib/clxsms.rb
87
+ - lib/clxsms/api.rb
88
+ - lib/clxsms/client.rb
89
+ - lib/clxsms/client/sendsms.rb
90
+ - lib/clxsms/configuration.rb
91
+ - lib/clxsms/connection.rb
92
+ - lib/clxsms/error.rb
93
+ - lib/clxsms/request.rb
94
+ - lib/clxsms/version.rb
95
+ homepage: https://bitbucket.org/standoutab/clxsms
96
+ licenses: []
97
+ metadata: {}
98
+ post_install_message:
99
+ rdoc_options: []
100
+ require_paths:
101
+ - lib
102
+ required_ruby_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ required_rubygems_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ requirements: []
113
+ rubyforge_project:
114
+ rubygems_version: 2.6.8
115
+ signing_key:
116
+ specification_version: 4
117
+ summary: API wrapper for Clxnetworks's SMS service
118
+ test_files: []