pswinlinkmobilitysmsapi 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 52a6bfd9de9b469d8d78b57922357a03808a8486a78e72f8dd5228eebc243975
4
+ data.tar.gz: 4f6d1655b94e1442c44e41511e609c2ff44a8028a9327e2c830103652338e14a
5
+ SHA512:
6
+ metadata.gz: 3900d03ce6a257754ae67d3c34fc6f09c3a77a7207081e31b76a9d5e5b4a5c0658f4f7f089e423ab711ac1b9a8c3a37db690d75dc1ff300248117f41d309dc96
7
+ data.tar.gz: 79b8882bf2410235d060c59c280f527e8a54bc78e481bcd5f2b750eec3eb91820f131804cdcb678f010bc175cd73749d069a39681d90131394237445f3d7e0e6
@@ -0,0 +1,9 @@
1
+ .idea
2
+ /.bundle/
3
+ /.yardoc
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /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 PSWinLinkMobilitySmsApi.gemspec
6
+ gemspec
@@ -0,0 +1,20 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ pswinlinkmobilitysmsapi (0.1.2)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ rake (10.5.0)
10
+
11
+ PLATFORMS
12
+ ruby
13
+
14
+ DEPENDENCIES
15
+ bundler (~> 1.17)
16
+ pswinlinkmobilitysmsapi!
17
+ rake (~> 10.0)
18
+
19
+ BUNDLED WITH
20
+ 1.17.2
@@ -0,0 +1,40 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "PSWinLinkMobilitySmsApi/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "pswinlinkmobilitysmsapi"
8
+ spec.version = PSWinLinkMobilitySmsApi::VERSION
9
+ spec.authors = ["Dmitry Ribalka"]
10
+ spec.email = ["dmitry.ribalka@gmail.com"]
11
+
12
+ spec.summary = %q{Link Mobility SMS API.}
13
+ spec.description = %q{Link Mobility SMS API}
14
+ spec.homepage = "https://github.com/agilie/PSWinLinkMobilitySmsApi"
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"] = "TODO: Set to 'https://rubygems.org/'"
20
+
21
+ spec.metadata["homepage_uri"] = spec.homepage
22
+ spec.metadata["source_code_uri"] = spec.homepage
23
+ spec.metadata["changelog_uri"] = spec.homepage
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", "~> 1.17"
39
+ spec.add_development_dependency "rake", "~> 10.0"
40
+ end
@@ -0,0 +1,35 @@
1
+ # PSWinLinkMobilitySmsApi
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/PSWinLinkMobilitySmsApi`. 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 'PSWinLinkMobilitySmsApi'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install PSWinLinkMobilitySmsApi
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]/PSWinLinkMobilitySmsApi.
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "PSWinLinkMobilitySmsApi"
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,17 @@
1
+ require "PSWinLinkMobilitySmsApi/version"
2
+ require "PSWinLinkMobilitySmsApi/sms"
3
+ require "net/http"
4
+ require "rubygems"
5
+ require "xmlsimple"
6
+
7
+ module PSWinLinkMobilitySmsApi
8
+ class Error < StandardError; end
9
+
10
+ class << self; attr_accessor :config, :url end
11
+
12
+ @url = 'https://simple.pswin.com/'
13
+
14
+ @config = {:username => "", :password => ""}
15
+
16
+
17
+ end
@@ -0,0 +1,69 @@
1
+ require "PSWinLinkMobilitySmsApi/version"
2
+
3
+ module PSWinLinkMobilitySmsApi
4
+
5
+ class Sms
6
+ attr_accessor :to, :message, :msgid, :from
7
+
8
+ attr_reader :status, :response_hash
9
+
10
+ def initialize(params = {})
11
+ @to = params[:to]
12
+ @message = params[:message].to_s.encode('ISO-8859-1')
13
+ @msgid = params[:msgid]
14
+ @from = params[:from]
15
+ @response = nil
16
+ @response_hash = {}
17
+ @status = nil
18
+ @delivered = false
19
+ end
20
+
21
+ def deliver
22
+ if valid?
23
+ handle_response(Net::HTTP.post_form(URI.parse(PSWinLinkMobilitySmsApi.url), params_hash))
24
+ end
25
+ delivered?
26
+ end
27
+
28
+ def delivered?
29
+ @delivered
30
+ end
31
+
32
+ def valid?
33
+ raise(ArgumentError, ":to is required") if @to.nil? or @to.empty?
34
+ raise(ArgumentError, ":message is required") if @message.nil? or @message.empty?
35
+ raise(ArgumentError, ":msgid is required") if @msgid.nil? or @msgid.empty?
36
+ not (@to.nil? or @to.empty? or @message.nil? or @message.empty? or @msgid.nil? or @msgid.empty?)
37
+ end
38
+
39
+ private
40
+
41
+ attr_accessor :response
42
+
43
+ def params_hash
44
+ {
45
+ :USER => PSWinLinkMobilitySmsApi.config[:username],
46
+ :PW => PSWinLinkMobilitySmsApi.config[:password],
47
+ :RCV => @to || "",
48
+ :TXT => @message || "",
49
+ :msgid => @msgid || "",
50
+ :SND => @from || ""
51
+ }
52
+ end
53
+
54
+ def handle_response(response)
55
+ @response = response
56
+ @response_hash = {}
57
+ unless @response.nil?
58
+ data = @response.body.to_s.split
59
+ @response_hash['error_code'] = data[0]
60
+ @response_hash['status'] = data[1]
61
+ @response_hash['content'] = @response.body
62
+
63
+ @status = @response_hash['status']
64
+ @delivered = @status == 'OK'
65
+ end
66
+ end
67
+ end
68
+
69
+ end
@@ -0,0 +1,3 @@
1
+ module PSWinLinkMobilitySmsApi
2
+ VERSION = "0.1.2"
3
+ end
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pswinlinkmobilitysmsapi
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - Dmitry Ribalka
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-01-15 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: '1.17'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.17'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: Link Mobility SMS API
42
+ email:
43
+ - dmitry.ribalka@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - Gemfile.lock
51
+ - PSWinLinkMobilitySmsApi.gemspec
52
+ - README.md
53
+ - Rakefile
54
+ - bin/console
55
+ - bin/setup
56
+ - lib/PSWinLinkMobilitySmsApi.rb
57
+ - lib/PSWinLinkMobilitySmsApi/sms.rb
58
+ - lib/PSWinLinkMobilitySmsApi/version.rb
59
+ homepage: https://github.com/agilie/PSWinLinkMobilitySmsApi
60
+ licenses: []
61
+ metadata:
62
+ homepage_uri: https://github.com/agilie/PSWinLinkMobilitySmsApi
63
+ source_code_uri: https://github.com/agilie/PSWinLinkMobilitySmsApi
64
+ changelog_uri: https://github.com/agilie/PSWinLinkMobilitySmsApi
65
+ post_install_message:
66
+ rdoc_options: []
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ requirements: []
80
+ rubygems_version: 3.0.1
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: Link Mobility SMS API.
84
+ test_files: []