Skip to content

Commit

Permalink
add latest out box
Browse files Browse the repository at this point in the history
show 3000 latest message
  • Loading branch information
mm580486 committed Apr 30, 2016
1 parent 41947e4 commit bb9d7b2
Show file tree
Hide file tree
Showing 11 changed files with 222 additions and 16 deletions.
1 change: 1 addition & 0 deletions .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/.rakeTasks

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions .idea/kave.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

87 changes: 87 additions & 0 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Kave

Kave negar offering advance sms servis for developer , you can send & recive sms in often services and app !
Kave negar offering advance sms servis for developer , you can send & receive sms in often services and app !
notice: this service only work in iran country
## Installation

Expand All @@ -25,22 +25,22 @@ Kave.configure do |config|
config.wsdl ='http://api.kavenegar.com/soap/v1.asmx?WSDL'
config.sender = 'number'

# You can user api key or username and password for authinticate å
# You can user api key or username and password for authinticate
config.api_key = 'api key'
# OR
config.username = 'kave username'
config.password = 'kave password'
end
```
[kavenegar.com](http://kavenegar.com/) for recive api key !
[kavenegar.com](http://kavenegar.com/) for receiver api key !
## Usage
alright ;) , now you can call kave function for send simply sms by loginfo or api key

```ruby
class HomeController < ApplicationController
def index

request=Kave::SendRequest.new({
request=Kave::SendRequestSimple.new({

message: 'سلام عزیز :)',
mobile: '09127105568',
Expand All @@ -61,8 +61,9 @@ for report issues contact me on twitter [@mm580486](https://twitter.com/mm580486

## persian tutorials

1-[send simply sms by kave gem](https://twitter.com/mm580486)
1-[youtube send simply sms by kave gem](https://twitter.com/mm580486)

2-[callback status code](http://kavenegar.com/public/documents/soap-document.pdf)
## License

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) .
Expand Down
1 change: 0 additions & 1 deletion lib/kave.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class Configuration
attr_accessor :api_key, :sender,:wsdl,:username,:password

def initialize

end

end
Expand Down
24 changes: 22 additions & 2 deletions lib/kave/response.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module Kave
class Response

class ResponseRequestSimple
attr_reader :response, :status,:statusmessage
def validate(response = nil,send_simple_by)
@response = response
Expand Down Expand Up @@ -32,4 +31,25 @@ def perform_validation

end
end


class ResponseLatestOutBox

attr_reader :response, :select

def validate(response = nil,send_latest_by)
@response = response
@send_simple_by=send_latest_by
perform_validation
return self
end


private
def perform_validation
body =@response[:selectlatest_by_apikey_response]
@select = body[:selectlatest_by_apikey_result][:api_select]
end

end
end
50 changes: 42 additions & 8 deletions lib/kave/send_request.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
require "savon"

module Kave

class SendRequest
class SendRequestSimple
attr_accessor :mobile, :message,:unixdate,:msgmode
attr_reader :response

Expand All @@ -13,19 +12,18 @@ def initialize(args = {})
@message = args.fetch(:message)
@unixdate = args.fetch(:unixdate) || 0
@wsdl = Savon.client(wsdl: Kave.configuration.wsdl, pretty_print_xml: true)
@response = Response.new
@response = ResponseRequestSimple.new
@msgmode = args.fetch(:msgmode) || 1
@username = Kave.configuration.username || ''
@password = Kave.configuration.password || ''

end

def call
@send_simple_by= unless Kave.configuration.api_key.nil?
:send_simple_by_apikey
else
:send_simple_by_login_info
end
:send_simple_by_apikey
else
:send_simple_by_login_info
end
response = @wsdl.call @send_simple_by, message: {
'apikey' =>Kave.configuration.api_key,
'username'=>@username,
Expand All @@ -38,5 +36,41 @@ def call
}
@response.validate(response.body,@send_simple_by)
end

end

class LatestOutBox
attr_accessor :pagesize
attr_reader :response

def initialize(args = {})
@pagesize = args.fetch(:pagesize)
@wsdl = Savon.client(wsdl: Kave.configuration.wsdl, pretty_print_xml: true)
@response = ResponseLatestOutBox.new
@username = Kave.configuration.username || ''
@password = Kave.configuration.password || ''
end

def call
@selectlatest_by=unless Kave.configuration.api_key.nil?
:selectlatest_by_apikey
else
:selectlatest_by_login_info
end

response = @wsdl.call :selectlatest_by_apikey, message: {
'apikey' =>Kave.configuration.api_key,
'pagesize'=>@pagesize.to_i,
'sender' => Kave.configuration.sender
}
@response.validate(response.body,@send_latest_by)
end

end






end

0 comments on commit bb9d7b2

Please sign in to comment.