growth-push 0.0.1
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.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/example/client.rb +17 -0
- data/example/notifications_api.rb +19 -0
- data/example/regist.rb +23 -0
- data/growth-push.gemspec +28 -0
- data/lib/growth_push.rb +28 -0
- data/lib/growth_push/api.rb +18 -0
- data/lib/growth_push/api/clients.rb +16 -0
- data/lib/growth_push/api/events.rb +19 -0
- data/lib/growth_push/api/notifications.rb +15 -0
- data/lib/growth_push/api/tags.rb +19 -0
- data/lib/growth_push/client.rb +20 -0
- data/lib/growth_push/configuration.rb +16 -0
- data/lib/growth_push/connection.rb +68 -0
- data/lib/growth_push/exception.rb +59 -0
- data/lib/growth_push/request.rb +50 -0
- data/lib/growth_push/response.rb +28 -0
- data/lib/growth_push/version.rb +3 -0
- data/spec/growth_push/api_spec.rb +25 -0
- data/spec/growth_push/client_spec.rb +25 -0
- data/spec/growth_push/connection_spec.rb +19 -0
- data/spec/growth_push/exception_spec.rb +10 -0
- data/spec/growth_push/request_spec.rb +20 -0
- data/spec/growth_push_spec.rb +19 -0
- data/spec/spec_helper.rb +5 -0
- metadata +164 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9fe622a87a8a8dfc3eb85a40b8e81835afc27061
|
4
|
+
data.tar.gz: befda0919bd952c10fdf0aea091b3bd2237c20aa
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 03579ae8e340783ec6d647c8e8ccb5062cc89ea6e03172e755f1858a91ba80ca6fd1358eddee713b6003daca07d679be8c9b1b6e4f41017aa0bf547b85321d88
|
7
|
+
data.tar.gz: 22231d1ad375e0b3ff3d47b68399162731bf86d6527cec249624a846f3f362e246d075fdeb7ef4cd4e98d1e330cdff58ab13a815a2d2dbd20c2e595ca7014a24
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 TODO: Write your name
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Growth::Push
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'growth-push'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install growth-push
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it ( http://github.com/<my-github-username>/growth-push/fork )
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/example/client.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
lib = File.expand_path('../../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
|
4
|
+
require 'growth_push'
|
5
|
+
|
6
|
+
GrowthPush.configure do |config|
|
7
|
+
config.application_id = 'your application id'
|
8
|
+
config.client_secret = 'your client secret'
|
9
|
+
config.api_host = 'api.growthpush.com'
|
10
|
+
config.api_version = 1
|
11
|
+
config.use_ssl = true
|
12
|
+
config.environment = 'development'
|
13
|
+
# config.debug = true
|
14
|
+
# config.options = {}
|
15
|
+
end
|
16
|
+
|
17
|
+
response = GrowthPush::Client.get('notifications', params)
|
@@ -0,0 +1,19 @@
|
|
1
|
+
lib = File.expand_path('../../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
|
4
|
+
require 'growth_push'
|
5
|
+
|
6
|
+
GrowthPush.configure do |config|
|
7
|
+
config.application_id = 'your application id'
|
8
|
+
config.client_secret = 'your client secret'
|
9
|
+
config.api_host = 'api.growthpush.com'
|
10
|
+
config.api_version = 1
|
11
|
+
config.use_ssl = true
|
12
|
+
config.environment = 'development'
|
13
|
+
# config.debug = true
|
14
|
+
# config.options = {}
|
15
|
+
end
|
16
|
+
|
17
|
+
params = {page: 1, limit: 50}
|
18
|
+
GrowthPush::API::Notifications.request(:get)
|
19
|
+
GrowthPush::API::Notifications.request(:get, params)
|
data/example/regist.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
lib = File.expand_path('../../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
|
4
|
+
require 'growth_push'
|
5
|
+
|
6
|
+
GrowthPush.configure do |config|
|
7
|
+
config.application_id = 'your application id'
|
8
|
+
config.client_secret = 'your client secret'
|
9
|
+
config.api_host = 'api.growthpush.com'
|
10
|
+
config.api_version = 1
|
11
|
+
config.environment = 'development'
|
12
|
+
config.use_ssl = true
|
13
|
+
# config.debug = true
|
14
|
+
# config.options = {}
|
15
|
+
end
|
16
|
+
|
17
|
+
params = {
|
18
|
+
token: "",
|
19
|
+
os: "ios",
|
20
|
+
environment: GrowthPush.configuration.environment
|
21
|
+
}
|
22
|
+
GrowthPush::API::Clients.request(:post, params)
|
23
|
+
GrowthPush::Client.post('clients', params)
|
data/growth-push.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'growth_push/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "growth-push"
|
8
|
+
spec.version = GrowthPush::VERSION
|
9
|
+
spec.authors = ["shiro16"]
|
10
|
+
spec.email = ["nyanyanyawan24@gmail.com"]
|
11
|
+
spec.summary = %q{Access for SIROK's GrowthPush API.}
|
12
|
+
spec.description = %q{Access for SIROK's GrowthPush API.}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "multi_json", "~> 1.3.7"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
spec.add_development_dependency "rspec", "~> 2.14.1"
|
26
|
+
spec.add_development_dependency "webmock", "~> 1.13.0"
|
27
|
+
spec.add_development_dependency "pry", "~> 0.9.12.2"
|
28
|
+
end
|
data/lib/growth_push.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
require 'net/http'
|
3
|
+
require 'net/https'
|
4
|
+
|
5
|
+
module GrowthPush
|
6
|
+
module_function
|
7
|
+
def configure(&block)
|
8
|
+
clear_configuration unless @_configuration
|
9
|
+
yield(configuration)
|
10
|
+
end
|
11
|
+
|
12
|
+
def configuration
|
13
|
+
@_configuration ||= Configuration.new
|
14
|
+
end
|
15
|
+
|
16
|
+
def clear_configuration
|
17
|
+
@_configuration = Configuration.new
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
require "growth_push/version"
|
22
|
+
require "growth_push/api"
|
23
|
+
require "growth_push/client"
|
24
|
+
require "growth_push/configuration"
|
25
|
+
require "growth_push/connection"
|
26
|
+
require "growth_push/request"
|
27
|
+
require "growth_push/response"
|
28
|
+
require "growth_push/exception"
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'growth_push/api/clients'
|
2
|
+
require 'growth_push/api/events'
|
3
|
+
require 'growth_push/api/tags'
|
4
|
+
require 'growth_push/api/notifications'
|
5
|
+
|
6
|
+
module GrowthPush
|
7
|
+
module API
|
8
|
+
def request(verb, params={}, endpoint=nil)
|
9
|
+
return nil if params.delete(:dummy_access) == true
|
10
|
+
endpoint = endpoint_for_class_name if endpoint.nil?
|
11
|
+
Client.send(verb, endpoint, params)
|
12
|
+
end
|
13
|
+
|
14
|
+
def endpoint_for_class_name
|
15
|
+
self.name.match(/::([a-zA-Z]+)$/)[1].downcase
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module GrowthPush
|
2
|
+
module Client
|
3
|
+
class << self
|
4
|
+
def get(endpoint, params={})
|
5
|
+
connection = Connection.new(params)
|
6
|
+
connection.get(endpoint)
|
7
|
+
end
|
8
|
+
|
9
|
+
def post(endpoint, params={})
|
10
|
+
connection = Connection.new(params)
|
11
|
+
connection.post(endpoint)
|
12
|
+
end
|
13
|
+
|
14
|
+
def put(endpoint, params={})
|
15
|
+
connection = Connection.new(params)
|
16
|
+
connection.put(endpoint)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module GrowthPush
|
2
|
+
class Configuration
|
3
|
+
attr_accessor :application_id, :secret, :api_host, :api_version, :use_ssl, :environment, :debug, :options
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@application_id = nil
|
7
|
+
@secret = nil
|
8
|
+
@api_host = nil
|
9
|
+
@api_version = nil
|
10
|
+
@use_ssl = true
|
11
|
+
@environment = nil
|
12
|
+
@debug = true
|
13
|
+
@options = {}
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'set'
|
2
|
+
|
3
|
+
module GrowthPush
|
4
|
+
class Connection
|
5
|
+
# A Set of allowed HTTP verbs.
|
6
|
+
METHODS = Set.new [:get, :post, :put]
|
7
|
+
|
8
|
+
attr_reader :headers, :params, :is_auth
|
9
|
+
|
10
|
+
def initialize(params={})
|
11
|
+
user_agent = params.delete(:user_agent)
|
12
|
+
@headers = setup_headers(user_agent)
|
13
|
+
@headers["User-Agent"] ||= "GrowthPush Ruby Library v#{VERSION}"
|
14
|
+
@params = setup_params(params)
|
15
|
+
end
|
16
|
+
|
17
|
+
def get(endpoint)
|
18
|
+
request(:get, endpoint)
|
19
|
+
end
|
20
|
+
|
21
|
+
def post(endpoint)
|
22
|
+
request(:post, endpoint)
|
23
|
+
end
|
24
|
+
|
25
|
+
def put(endpoint)
|
26
|
+
request(:put, endpoint)
|
27
|
+
end
|
28
|
+
|
29
|
+
def request(method, endpoint)
|
30
|
+
raise ArgumentError, "unknown HTTP method: #{method}" unless METHODS.include?(method)
|
31
|
+
|
32
|
+
request = Request.new(method, "#{GrowthPush.configuration.api_version}/#{endpoint}", headers, params)
|
33
|
+
|
34
|
+
response = http.start do |http|
|
35
|
+
http.request request.create
|
36
|
+
end
|
37
|
+
|
38
|
+
Response.handle(response)
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
def http
|
43
|
+
use_ssl = ssl?
|
44
|
+
http = Net::HTTP.new(
|
45
|
+
GrowthPush.configuration.api_host,
|
46
|
+
use_ssl ? 443 : 80
|
47
|
+
)
|
48
|
+
http.use_ssl = use_ssl
|
49
|
+
http
|
50
|
+
end
|
51
|
+
|
52
|
+
def setup_headers(user_agent=nil, headers={})
|
53
|
+
headers["User-Agent"] = user_agent if user_agent
|
54
|
+
headers
|
55
|
+
end
|
56
|
+
|
57
|
+
def setup_params(params)
|
58
|
+
params[:applicationId] = GrowthPush.configuration.application_id
|
59
|
+
params[:secret] = GrowthPush.configuration.secret
|
60
|
+
params[:environment] = GrowthPush.configuration.environment
|
61
|
+
params
|
62
|
+
end
|
63
|
+
|
64
|
+
def ssl?
|
65
|
+
GrowthPush.configuration.use_ssl == true
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module GrowthPush
|
2
|
+
class Exception < StandardError
|
3
|
+
attr_accessor :status, :code
|
4
|
+
|
5
|
+
class << self
|
6
|
+
def handle_response(response)
|
7
|
+
klass = klass_for_status(response.code.to_i)
|
8
|
+
exception = if klass
|
9
|
+
klass.new(response.code, response.message)
|
10
|
+
else
|
11
|
+
Exception.new(response.code.to_i, response.code, response.message)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def klass_for_status(status)
|
16
|
+
case status
|
17
|
+
when 400
|
18
|
+
BadRequest
|
19
|
+
when 401
|
20
|
+
Unauthorized
|
21
|
+
when 404
|
22
|
+
NotFound
|
23
|
+
when 500
|
24
|
+
InternalServerError
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def initialize(status, code, message)
|
30
|
+
@status = status
|
31
|
+
@code = code
|
32
|
+
super message
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
class BadRequest < Exception
|
37
|
+
def initialize(code, message)
|
38
|
+
super 400, code, message
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
class Unauthorized < Exception
|
43
|
+
def initialize(code, message)
|
44
|
+
super 401, code, message
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
class NotFound < Exception
|
49
|
+
def initialize(code, message)
|
50
|
+
super 404, code, message
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
class InternalServerError < Exception
|
55
|
+
def initialize(code, message)
|
56
|
+
super 500, code, message
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
|
3
|
+
module GrowthPush
|
4
|
+
class Request
|
5
|
+
attr_reader :method, :endpoint, :headers, :params
|
6
|
+
|
7
|
+
def initialize(method, endpoint, headers, params)
|
8
|
+
@method = method
|
9
|
+
@endpoint = endpoint
|
10
|
+
@headers = headers
|
11
|
+
@params = params
|
12
|
+
end
|
13
|
+
|
14
|
+
def create
|
15
|
+
send(method)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
def get
|
20
|
+
uri = generate_uri_from_params(endpoint, params)
|
21
|
+
request = Net::HTTP::Get.new(uri)
|
22
|
+
headers.each { |k, v| request[k.to_s] = v.to_s}
|
23
|
+
request
|
24
|
+
end
|
25
|
+
|
26
|
+
def post
|
27
|
+
request = Net::HTTP::Post.new("/#{endpoint}")
|
28
|
+
request.set_form_data(params)
|
29
|
+
headers.each { |k, v| request[k.to_s] = v.to_s}
|
30
|
+
request
|
31
|
+
end
|
32
|
+
|
33
|
+
def put
|
34
|
+
request = Net::HTTP::Put.new("/#{endpoint}")
|
35
|
+
request.set_form_data(params)
|
36
|
+
headers.each { |k, v| request[k.to_s] = v.to_s}
|
37
|
+
request
|
38
|
+
end
|
39
|
+
|
40
|
+
def generate_uri_from_params(endpoint, params)
|
41
|
+
if params.empty?
|
42
|
+
"/#{endpoint}"
|
43
|
+
else
|
44
|
+
query_string = params.collect {|k, v| "#{CGI.escape(k.to_s)}=#{CGI.escape(v.to_s)}" }.join("&")
|
45
|
+
"/#{endpoint}?#{query_string}"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'multi_json'
|
2
|
+
|
3
|
+
module GrowthPush
|
4
|
+
class Response
|
5
|
+
def self.handle(response)
|
6
|
+
_response = if response_body_not_json?(response.body)
|
7
|
+
(response.body == 'true')
|
8
|
+
else
|
9
|
+
begin
|
10
|
+
::MultiJson.load(response.body)
|
11
|
+
rescue MultiJson::DecodeError
|
12
|
+
response.body
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
if (200...300).include?(response.code.to_i)
|
17
|
+
_response
|
18
|
+
else
|
19
|
+
Exception.handle_response(response)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.response_body_not_json?(body)
|
24
|
+
body == 'true' || body == 'false' || body == '[]'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe GrowthPush::API::Clients do
|
6
|
+
before do
|
7
|
+
GrowthPush.configure do |config|
|
8
|
+
config.application_id = 0
|
9
|
+
config.secret = 'test secret'
|
10
|
+
config.api_host = 'api.growthpush.com'
|
11
|
+
config.api_version = 1
|
12
|
+
config.use_ssl = true
|
13
|
+
config.environment = 'development'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
before { stub_request(:put, /\w+/).to_return(:status => 200, :body => '{}') }
|
18
|
+
|
19
|
+
describe "#update" do
|
20
|
+
it "" do
|
21
|
+
GrowthPush::API::Clients.update
|
22
|
+
a_request(:put, "https://#{GrowthPush.configuration.api_host}/#{GrowthPush.configuration.api_version}/clients/").should have_been_made.once
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe GrowthPush::Client do
|
6
|
+
before do
|
7
|
+
GrowthPush.configure do |config|
|
8
|
+
config.application_id = 0
|
9
|
+
config.secret = 'test secret'
|
10
|
+
config.api_host = 'api.growthpush.com'
|
11
|
+
config.api_version = 1
|
12
|
+
config.use_ssl = true
|
13
|
+
config.environment = 'development'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
context "#get" do
|
18
|
+
end
|
19
|
+
|
20
|
+
context "#post" do
|
21
|
+
end
|
22
|
+
|
23
|
+
context "#put" do
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe GrowthPush::Connection do
|
6
|
+
before { stub_request(:get, /\w+/).to_return(:status => 200, :body => '{}') }
|
7
|
+
|
8
|
+
context "#get" do
|
9
|
+
end
|
10
|
+
|
11
|
+
context "call not allow http method" do
|
12
|
+
it "should raise an argument error" do
|
13
|
+
expect {
|
14
|
+
conn = GrowthPush::Connection.new({})
|
15
|
+
conn.request(:test, 'notifications')
|
16
|
+
}.to raise_error(ArgumentError)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe GrowthPush::Exception do
|
6
|
+
it 'should properly set its message for inspect' do
|
7
|
+
err = GrowthPush::Exception.new(400, "400", 'error message')
|
8
|
+
err.inspect.should == '#<GrowthPush::Exception: error message>'
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe GrowthPush::Request do
|
6
|
+
context "vebs is :get" do
|
7
|
+
subject { GrowthPush::Request.new(:get, 'notifications', {}, {}).create }
|
8
|
+
it ("should return instance of Net::HTTP:Get") { should be_an_instance_of(Net::HTTP::Get) }
|
9
|
+
end
|
10
|
+
|
11
|
+
context "vebs is :post" do
|
12
|
+
subject { GrowthPush::Request.new(:post, 'clients', {}, {}).create }
|
13
|
+
it ("should return instance of Net::HTTP:Post") { should be_an_instance_of(Net::HTTP::Post) }
|
14
|
+
end
|
15
|
+
|
16
|
+
context "vebs is :put" do
|
17
|
+
subject { GrowthPush::Request.new(:put, 'clients/test', {}, {}).create }
|
18
|
+
it ("should return instance of Net::HTTP:Delete") { should be_an_instance_of(Net::HTTP::Put) }
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe GrowthPush do
|
6
|
+
context 'configure set applicaton_id secret environment' do
|
7
|
+
before do
|
8
|
+
GrowthPush.configure do |config|
|
9
|
+
config.application_id = 0
|
10
|
+
config.secret = 'test secret'
|
11
|
+
config.environment = 'development'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
it { GrowthPush.configuration.application_id.should == 0 }
|
16
|
+
it { GrowthPush.configuration.secret.should == 'test secret' }
|
17
|
+
it { GrowthPush.configuration.environment.should == 'development' }
|
18
|
+
end
|
19
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,164 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: growth-push
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- shiro16
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-03-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: multi_json
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.3.7
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.3.7
|
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.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '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: 2.14.1
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 2.14.1
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: webmock
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.13.0
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 1.13.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.9.12.2
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ~>
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.9.12.2
|
97
|
+
description: Access for SIROK's GrowthPush API.
|
98
|
+
email:
|
99
|
+
- nyanyanyawan24@gmail.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- .gitignore
|
105
|
+
- Gemfile
|
106
|
+
- LICENSE.txt
|
107
|
+
- README.md
|
108
|
+
- Rakefile
|
109
|
+
- example/client.rb
|
110
|
+
- example/notifications_api.rb
|
111
|
+
- example/regist.rb
|
112
|
+
- growth-push.gemspec
|
113
|
+
- lib/growth_push.rb
|
114
|
+
- lib/growth_push/api.rb
|
115
|
+
- lib/growth_push/api/clients.rb
|
116
|
+
- lib/growth_push/api/events.rb
|
117
|
+
- lib/growth_push/api/notifications.rb
|
118
|
+
- lib/growth_push/api/tags.rb
|
119
|
+
- lib/growth_push/client.rb
|
120
|
+
- lib/growth_push/configuration.rb
|
121
|
+
- lib/growth_push/connection.rb
|
122
|
+
- lib/growth_push/exception.rb
|
123
|
+
- lib/growth_push/request.rb
|
124
|
+
- lib/growth_push/response.rb
|
125
|
+
- lib/growth_push/version.rb
|
126
|
+
- spec/growth_push/api_spec.rb
|
127
|
+
- spec/growth_push/client_spec.rb
|
128
|
+
- spec/growth_push/connection_spec.rb
|
129
|
+
- spec/growth_push/exception_spec.rb
|
130
|
+
- spec/growth_push/request_spec.rb
|
131
|
+
- spec/growth_push_spec.rb
|
132
|
+
- spec/spec_helper.rb
|
133
|
+
homepage: ''
|
134
|
+
licenses:
|
135
|
+
- MIT
|
136
|
+
metadata: {}
|
137
|
+
post_install_message:
|
138
|
+
rdoc_options: []
|
139
|
+
require_paths:
|
140
|
+
- lib
|
141
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - '>='
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
|
+
requirements:
|
148
|
+
- - '>='
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: '0'
|
151
|
+
requirements: []
|
152
|
+
rubyforge_project:
|
153
|
+
rubygems_version: 2.0.14
|
154
|
+
signing_key:
|
155
|
+
specification_version: 4
|
156
|
+
summary: Access for SIROK's GrowthPush API.
|
157
|
+
test_files:
|
158
|
+
- spec/growth_push/api_spec.rb
|
159
|
+
- spec/growth_push/client_spec.rb
|
160
|
+
- spec/growth_push/connection_spec.rb
|
161
|
+
- spec/growth_push/exception_spec.rb
|
162
|
+
- spec/growth_push/request_spec.rb
|
163
|
+
- spec/growth_push_spec.rb
|
164
|
+
- spec/spec_helper.rb
|