kave 0.1.1

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
+ SHA1:
3
+ metadata.gz: cd88a92b8e8b247cd62f88bf3303682cffa21d76
4
+ data.tar.gz: da656f0c33338c719a4e549c69e02285b2d9aac5
5
+ SHA512:
6
+ metadata.gz: 4998d1532065d4f8bec6e6989b6eab911c280f953b6b52f383ffc70f74e3fe17564720b8bb35be18584536bc4c69966fdb941ee176d78cb7e31fc93a0708dd03
7
+ data.tar.gz: 2665503cbb30a60ff7e104202d9793c599297564aedbcdc5b54e98a4ad37dbae1c2b39cde33d452241735db6545a6f1de6ed8fdcff05a0f5d8e9d7a791e963dc
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ /.bundle/
2
+ /.yardoc
3
+
4
+ /.idea/
5
+ /Gemfile.lock
6
+ /_yardoc/
7
+ /coverage/
8
+ /doc/
9
+ /pkg/
10
+ /spec/reports/
11
+ /tmp/
12
+ .DS_Store
13
+ .DS_Store?
14
+ ._*
15
+ .Spotlight-V100
16
+ .Trashes
17
+ ehthumbs.db
18
+ Thumbs.db
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.3
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 kave.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 mohammad mahmoudi
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,70 @@
1
+ # Kave
2
+
3
+ Kave negar offering advance sms servis for developer , you can send & receive sms in often services and app !
4
+ notice: this service only work in iran country
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'kave'
11
+ ```
12
+
13
+ And then execute:
14
+ ```
15
+ $ bundle install
16
+ ```
17
+ Or install it yourself(localy) as:
18
+ ```ruby
19
+ $ gem install kave
20
+ ```
21
+ And create init file on config directory(kave.rb):
22
+
23
+ ```ruby
24
+ Kave.configure do |config|
25
+ config.wsdl ='http://api.kavenegar.com/soap/v1.asmx?WSDL'
26
+ config.sender = 'number'
27
+
28
+ # You can user api key or username and password for authinticate
29
+ config.api_key = 'api key'
30
+ # OR
31
+ config.username = 'kave username'
32
+ config.password = 'kave password'
33
+ end
34
+ ```
35
+ [kavenegar.com](http://kavenegar.com/) for receiver api key !
36
+ ## Usage
37
+ alright ;) , now you can call kave function for send simply sms by loginfo or api key
38
+
39
+ ```ruby
40
+ class HomeController < ApplicationController
41
+ def index
42
+
43
+ request=Kave::SendRequestSimple.new({
44
+
45
+ message: 'سلام عزیز :)',
46
+ mobile: '09127105568',
47
+ #optional
48
+ unixdate: by default 0 ,
49
+ msgmode: by default 1
50
+ })
51
+
52
+ res=request.call
53
+ render :text=>{status_message_only_farsi: res.statusmessage,status_code: res.status}
54
+ end
55
+ end
56
+
57
+
58
+ ```
59
+
60
+ for report issues contact me on twitter [@mm580486](https://twitter.com/mm580486)
61
+
62
+ ## persian tutorials
63
+
64
+ 1-[youtube send simply sms by kave gem](https://twitter.com/mm580486)
65
+
66
+ 2-[callback status code](http://kavenegar.com/public/documents/soap-document.pdf)
67
+ ## License
68
+
69
+ The gem is available as open source under the terms of the [mohammad mahmoudi](https://twitter.com/mm580486) and [kave negar](http://kavenegar.com/support/about) .
70
+
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "kave"
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
data/bin/setup ADDED
@@ -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
data/kave.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'kave/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "kave"
8
+ spec.version = Kave::VERSION
9
+ spec.authors = ["mohammad mahmoudi"]
10
+ spec.email = ["mm580486@gmail.com"]
11
+
12
+ spec.summary = %q{Send SMS}
13
+ spec.description = %q{Send SMS by kavenegar services}
14
+ spec.homepage = "https://github.com/mm580486/kave"
15
+ spec.license = "mohammad mahmoudi"
16
+
17
+ spec.add_dependency 'savon', ['~> 2.0']
18
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.10"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ end
data/lib/kave.rb ADDED
@@ -0,0 +1,22 @@
1
+ require "kave/version"
2
+ require "kave/send_request"
3
+ require "kave/response"
4
+
5
+
6
+ module Kave
7
+ class << self
8
+ attr_accessor :configuration
9
+ end
10
+ def self.configure
11
+ self.configuration ||= Configuration.new
12
+ yield configuration
13
+ end
14
+
15
+ class Configuration
16
+ attr_accessor :api_key, :sender,:wsdl,:username,:password
17
+
18
+ def initialize
19
+ end
20
+
21
+ end
22
+ end
@@ -0,0 +1,53 @@
1
+ module Kave
2
+ class ResponseRequestSimple
3
+ attr_reader :response, :status,:statusmessage
4
+ def validate(response = nil,send_simple_by)
5
+ @response = response
6
+ @send_simple_by=send_simple_by
7
+ perform_validation
8
+ return self
9
+ end
10
+
11
+ def valid?
12
+ @valid
13
+ end
14
+
15
+ private
16
+ def perform_validation
17
+ raise ArgumentError, 'not a valid response' if @response.nil?
18
+
19
+ body = if @send_simple_by==:send_simple_by_apikey
20
+ @response[:send_simple_by_apikey_response]
21
+ else
22
+ @response[:send_simple_by_login_info_response]
23
+ end
24
+ @status = body[:status].to_i
25
+ @statusmessage = body[:statusmessage]
26
+ unless @status == 200
27
+ @valid = false
28
+ else
29
+ @valid=true
30
+ end
31
+
32
+ end
33
+ end
34
+
35
+
36
+ class ResponseLatestOutBox
37
+
38
+ attr_reader :response, :select
39
+ def validate(response = nil,send_latest_by)
40
+ @response = response
41
+ @send_simple_by=send_latest_by
42
+ perform_validation
43
+ return self
44
+ end
45
+ private
46
+ def perform_validation
47
+ raise ArgumentError, 'not a valid response' if @response.nil?
48
+ body =@response[:selectlatest_by_apikey_response]
49
+ @select = body[:selectlatest_by_apikey_result][:api_select]
50
+ end
51
+
52
+ end
53
+ end
@@ -0,0 +1,76 @@
1
+ require "savon"
2
+
3
+ module Kave
4
+ class SendRequestSimple
5
+ attr_accessor :mobile, :message,:unixdate,:msgmode
6
+ attr_reader :response
7
+
8
+ def initialize(args = {})
9
+ args[:unixdate] ||= nil
10
+ args[:msgmode] ||= nil
11
+ @mobile = args.fetch(:mobile)
12
+ @message = args.fetch(:message)
13
+ @unixdate = args.fetch(:unixdate) || 0
14
+ @wsdl = Savon.client(wsdl: Kave.configuration.wsdl, pretty_print_xml: true)
15
+ @response = ResponseRequestSimple.new
16
+ @msgmode = args.fetch(:msgmode) || 1
17
+ @username = Kave.configuration.username || ''
18
+ @password = Kave.configuration.password || ''
19
+ end
20
+
21
+ def call
22
+ @send_simple_by= unless Kave.configuration.api_key.nil?
23
+ :send_simple_by_apikey
24
+ else
25
+ :send_simple_by_login_info
26
+ end
27
+ response = @wsdl.call @send_simple_by, message: {
28
+ 'apikey' =>Kave.configuration.api_key,
29
+ 'username'=>@username,
30
+ 'password'=>@password,
31
+ 'receptor'=> {string:@mobile},
32
+ 'message' => @message,
33
+ 'sender' => Kave.configuration.sender,
34
+ 'unixdate'=>@unixdate,
35
+ 'msgmode'=>@msgmode
36
+ }
37
+ @response.validate(response.body,@send_simple_by)
38
+ end
39
+
40
+ end
41
+
42
+ class LatestOutBox
43
+ attr_accessor :pagesize
44
+ attr_reader :response
45
+
46
+ def initialize(args = {})
47
+ @pagesize = args.fetch(:pagesize)
48
+ @wsdl = Savon.client(wsdl: Kave.configuration.wsdl, pretty_print_xml: true)
49
+ @response = ResponseLatestOutBox.new
50
+ @username = Kave.configuration.username || ''
51
+ @password = Kave.configuration.password || ''
52
+ end
53
+
54
+ def call
55
+ @selectlatest_by=unless Kave.configuration.api_key.nil?
56
+ :selectlatest_by_apikey
57
+ else
58
+ :selectlatest_by_login_info
59
+ end
60
+ @pagesize=if @pagesize < 2;2;else;@pagesize;end
61
+ response = @wsdl.call :selectlatest_by_apikey, message: {
62
+ 'apikey' =>Kave.configuration.api_key,
63
+ 'pagesize'=>@pagesize.to_i,
64
+ 'sender' => Kave.configuration.sender
65
+ }
66
+ @response.validate(response.body,@send_latest_by)
67
+ end
68
+
69
+ end
70
+
71
+
72
+
73
+
74
+
75
+
76
+ end
@@ -0,0 +1,3 @@
1
+ module Kave
2
+ VERSION = "0.1.1"
3
+ end
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kave
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - mohammad mahmoudi
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-05-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: savon
15
+ version_requirements: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ requirement: !ruby/object:Gem::Requirement
21
+ requirements:
22
+ - - ~>
23
+ - !ruby/object:Gem::Version
24
+ version: '2.0'
25
+ prerelease: false
26
+ type: :runtime
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.10'
34
+ requirement: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ~>
37
+ - !ruby/object:Gem::Version
38
+ version: '1.10'
39
+ prerelease: false
40
+ type: :development
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ requirement: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ~>
51
+ - !ruby/object:Gem::Version
52
+ version: '10.0'
53
+ prerelease: false
54
+ type: :development
55
+ description: Send SMS by kavenegar services
56
+ email:
57
+ - mm580486@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .gitignore
63
+ - .idea/.name
64
+ - .idea/.rakeTasks
65
+ - .idea/kave.iml
66
+ - .idea/misc.xml
67
+ - .idea/modules.xml
68
+ - .idea/vcs.xml
69
+ - .idea/workspace.xml
70
+ - .travis.yml
71
+ - CODE_OF_CONDUCT.md
72
+ - Gemfile
73
+ - LICENSE.txt
74
+ - README.md
75
+ - Rakefile
76
+ - bin/console
77
+ - bin/setup
78
+ - kave.gemspec
79
+ - lib/kave.rb
80
+ - lib/kave/response.rb
81
+ - lib/kave/send_request.rb
82
+ - lib/kave/version.rb
83
+ homepage: https://github.com/mm580486/kave
84
+ licenses:
85
+ - mohammad mahmoudi
86
+ metadata: {}
87
+ post_install_message:
88
+ rdoc_options: []
89
+ require_paths:
90
+ - lib
91
+ required_ruby_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - '>='
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - '>='
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ requirements: []
102
+ rubyforge_project:
103
+ rubygems_version: 2.4.5
104
+ signing_key:
105
+ specification_version: 4
106
+ summary: Send SMS
107
+ test_files: []