instasent 0.1.3

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
+ SHA1:
3
+ metadata.gz: 9c431bb66f8a478f98a141a65c7373a7bbea19c2
4
+ data.tar.gz: f07c919720d0c81e7b5d24c0eebc2b6201722227
5
+ SHA512:
6
+ metadata.gz: a7d44742f3679519042809c07385d792eb49adf3e2903a0f3558539fbe8fa74558fad158d8779d6d6e18c487793d020ddd6b88bbb1fee60e785a53d1cf119b1a
7
+ data.tar.gz: 31f27a595723ad8637b7a8919fbc05259e29e0d9f91028805b7d963e871ca1934ddaf9d096f31aa6d0e490108a1798e3c2aa0811c7c8419bff24401cb50d6cb0
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ .idea/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in instasent.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Senen
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.
@@ -0,0 +1,45 @@
1
+ Welcome to __Instasent Ruby SDK__. This repository contains Instasent's Python SDK and samples for REST API.
2
+
3
+ ## Installation
4
+
5
+ The easiest way to install the instasent package is either via command line:
6
+
7
+ ```
8
+ $ gem install instasent
9
+ ```
10
+ And then execute:
11
+
12
+ $ bundle
13
+ or including the following in your Gemfile:
14
+
15
+ ```
16
+ gem 'instasent'
17
+ ```
18
+
19
+ ## Example
20
+ ### Send an SMS
21
+ You can check 'examples/send-sms.py' file.
22
+ ```ruby
23
+ require 'instasent'
24
+
25
+ client = Instasent::Client.new('my-token')
26
+
27
+ response = client.send_sms('Mi company', '+34666666666', 'test message')
28
+
29
+ puts response['response_code']
30
+ puts response['response_body']
31
+ ```
32
+ ## Available functions
33
+ ```
34
+ client.send_sms(sender, to, text)
35
+ client.get_sms(page, per_page)
36
+ client.get_sms_by_id(message_id)
37
+ ```
38
+ ## Documentation
39
+ Complete documentation at :
40
+ [http://docs.instasent.com/](http://docs.instasent.com/).
41
+
42
+ # Getting help
43
+
44
+ If you need help installing or using the library, please contact Instasent Support at support@instasent.com first.
45
+ If you've instead found a bug in the library or would like new features added, go ahead and open issues or pull requests against this repo!
@@ -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 "instasent"
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,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,8 @@
1
+ $LOAD_PATH << '.'
2
+ require 'instasent'
3
+
4
+ client = Instasent::Client.new('my-token')
5
+ response = client.get_sms(1, 50)
6
+
7
+ puts response['response_body']
8
+ puts response['response_code']
@@ -0,0 +1,8 @@
1
+ $LOAD_PATH << '.'
2
+ require 'instasent'
3
+
4
+ client = Instasent::Client.new('my-token')
5
+ response = client.get_sms_by_id('id')
6
+
7
+ puts response['response_body']
8
+ puts response['response_code']
@@ -0,0 +1,8 @@
1
+ $LOAD_PATH << '.'
2
+ require 'instasent'
3
+
4
+ client = Instasent::Client.new('my-token')
5
+ response = client.send_sms('My company', '+34666666666', 'test message')
6
+
7
+ puts response['response_body']
8
+ puts response['response_code']
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'instasent/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "instasent"
8
+ spec.version = Instasent::VERSION
9
+ spec.authors = ["Instasent"]
10
+ spec.email = ["support@instasent.com"]
11
+
12
+ spec.summary = "Implementation of the Instasent SMS lib for Ruby"
13
+ spec.description = "Implementation of the Instasent SMS lib for Ruby"
14
+ spec.homepage = "https://github.com/instasent/instasent-ruby-lib"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ # if spec.respond_to?(:metadata)
20
+ # spec.metadata['allowed_push_host'] = "Set to 'http://mygemserver.com'"
21
+ # else
22
+ # raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ # end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_development_dependency "bundler", "~> 1.12"
31
+ spec.add_development_dependency "rake", "~> 10.0"
32
+ end
@@ -0,0 +1,91 @@
1
+ require "instasent/version"
2
+ require "net/https"
3
+ require "json"
4
+
5
+ module Instasent
6
+ class Client
7
+
8
+ @@rootEndpoint = "http://api.instasent.com/"
9
+ @@secureChannel = "https://api.instasent.com/"
10
+ @@use_secure_channel = true
11
+
12
+ def initialize(token, use_secure_channel=true)
13
+ @@token = token
14
+ @@use_secure_channel = use_secure_channel
15
+ end
16
+
17
+ def send_sms(sender, to, text, client_id='')
18
+
19
+ if @use_secure_channel
20
+ url = @@secureChannel + "sms/"
21
+ else
22
+ url = @@rootEndpoint + "sms/"
23
+ end
24
+
25
+ http_method = 'POST'
26
+
27
+ data = {'from' => sender, 'to' => to, 'text' => text}
28
+
29
+ response = self.execute_request(url, http_method, data)
30
+
31
+ return response
32
+
33
+ end
34
+
35
+ def get_sms(page=1, per_page=10)
36
+
37
+ if @use_secure_channel
38
+ url = @@secureChannel + "sms/?page=" + page.to_s + "per_page=" + per_page.to_s
39
+ else
40
+ url = @@rootEndpoint + "sms/?page=" + page.to_s + "per_page=" + per_page.to_s
41
+ end
42
+
43
+ http_method = 'GET'
44
+
45
+ response = self.execute_request(url, http_method)
46
+
47
+ return response
48
+
49
+ end
50
+
51
+ def get_sms_by_id(id)
52
+
53
+ if @@use_secure_channel
54
+ url = @@secureChannel + 'sms/' + id
55
+ else
56
+ url = @@rootEndpoint + 'sms/' + id
57
+ end
58
+
59
+ http_method = 'GET'
60
+
61
+ response = self.execute_request(url, http_method)
62
+
63
+ return response
64
+
65
+ end
66
+
67
+ def execute_request(url='', http_method='', data='')
68
+
69
+ url_parsed = URI.parse(url)
70
+
71
+ if http_method=='GET'
72
+ req = Net::HTTP::Get.new(url_parsed.to_s)
73
+ else
74
+ req = Net::HTTP::Post.new(url_parsed.to_s, initheader = {'Content-Type' => 'application/json'})
75
+ req.body = data.to_json
76
+ end
77
+
78
+ req.add_field("Authorization", "Bearer "+@@token.to_s)
79
+
80
+ res = Net::HTTP.start(url_parsed.host, url_parsed.port) { |http|
81
+ http.request(req)
82
+ }
83
+
84
+ return {'response_body' => res.body, 'response_code' => res.code}
85
+
86
+ end
87
+
88
+ end
89
+
90
+
91
+ end
@@ -0,0 +1,3 @@
1
+ module Instasent
2
+ VERSION = "0.1.3"
3
+ end
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: instasent
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.3
5
+ platform: ruby
6
+ authors:
7
+ - Instasent
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-05-24 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.12'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.12'
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: Implementation of the Instasent SMS lib for Ruby
42
+ email:
43
+ - support@instasent.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - .gitignore
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - bin/console
54
+ - bin/setup
55
+ - examples/get_sms.rb
56
+ - examples/get_sms_by_id.rb
57
+ - examples/send_sms.rb
58
+ - instasent.gemspec
59
+ - lib/instasent.rb
60
+ - lib/instasent/version.rb
61
+ homepage: https://github.com/instasent/instasent-ruby-lib
62
+ licenses:
63
+ - MIT
64
+ metadata: {}
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
+ rubyforge_project:
81
+ rubygems_version: 2.0.14
82
+ signing_key:
83
+ specification_version: 4
84
+ summary: Implementation of the Instasent SMS lib for Ruby
85
+ test_files: []