appboy 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b9b08323e1d2602a33183a99f18a06a7bb59ad1e
4
+ data.tar.gz: 984094644be733e86940bb0e4b6d2c0dcf397d36
5
+ SHA512:
6
+ metadata.gz: 4f39f353d4618c26b0b340ea7580d535042f40baf1b03e74c578d80066db094b70e65f283e1a408a54b6946087a436417788da032265e2e4168131fcce10fc8c
7
+ data.tar.gz: ec645bebf908780c2d633bdb18b7e211b72d304024ccf5afcb02e519921db65b49373bd3626489e4dd8573779a6ae2fcc2427fa29502800d901535907c1cbc8b
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in appboy.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Josh Nussbaum
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.
@@ -0,0 +1,75 @@
1
+ # Appboy
2
+
3
+ A wrapper for the Appboy REST API using HTTParty
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'appboy'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install appboy
18
+
19
+ ## Examples
20
+
21
+ ### Initializing API
22
+
23
+ ```ruby
24
+ api = Appboy::API.new('<secret>', '<app-group-id>')
25
+ ```
26
+
27
+ ### Track User
28
+
29
+ ```ruby
30
+ api.track [{external_id: 123,
31
+ first_name: 'John',
32
+ last_name: 'Smith',
33
+ gender: 'male',
34
+ email: 'jsmith@example.com'}]
35
+ ```
36
+
37
+ ### Track Event
38
+
39
+ ```ruby
40
+ events = [
41
+ {external_id: 123, name: 'add-to-cart', time: Time.now}
42
+ ]
43
+ api.track [], events
44
+ ```
45
+
46
+ ### Track Purchase
47
+ ### Send Message
48
+
49
+ ```ruby
50
+ message = {android_push: {alert: 'Hello Android'},
51
+ apple_push: {alert: "Hello iOS"}}
52
+
53
+ user_ids = [123, 456]
54
+
55
+ api.send_message(message, user_ids)
56
+ ```
57
+
58
+ ### Schedule Message
59
+
60
+ ```ruby
61
+ message = {android_push: {alert: 'Hello Android'},
62
+ apple_push: {alert: "Hello iOS"}}
63
+ segment_id = '<segment id>'
64
+ send_at = Time.new(2014, 3, 12)
65
+
66
+ api.schedule_message(send_at, message, segment_id)
67
+ ```
68
+
69
+ ## Contributing
70
+
71
+ 1. Fork it
72
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
73
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
74
+ 4. Push to the branch (`git push origin my-new-feature`)
75
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -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 'appboy/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "appboy"
8
+ spec.version = Appboy::VERSION
9
+ spec.authors = ["Josh Nussbaum"]
10
+ spec.email = ["josh@godynamo.com"]
11
+ spec.description = %q{Appboy wrapper}
12
+ spec.summary = %q{A wrapper for the Appboy REST API, track users/events/purchases, send & schedule messages}
13
+ spec.homepage = "http://appboy.com"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
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 'httparty'
22
+ spec.add_development_dependency "bundler", "~> 1.3"
23
+ spec.add_development_dependency "rake"
24
+ spec.add_development_dependency "rspec"
25
+ end
@@ -0,0 +1,6 @@
1
+ require "appboy/version"
2
+ require 'httparty'
3
+
4
+ module Appboy
5
+ autoload :API, "appboy/api"
6
+ end
@@ -0,0 +1,42 @@
1
+ module Appboy
2
+ class API
3
+ include HTTParty
4
+
5
+ base_uri 'https://api.appboy.com'
6
+
7
+ def initialize(secret, app_group_id)
8
+ @secret, @app_group_id = secret, app_group_id
9
+ end
10
+
11
+ def track(attributes, events=[], purchases=[])
12
+ post '/users/track', company_secret: @secret,
13
+ app_group_id: @app_group_id,
14
+ attributes: attributes,
15
+ events: events,
16
+ purchases: purchases
17
+ end
18
+
19
+ def send_message(message, user_ids, segment_id = nil)
20
+ post '/messages/send', company_secret: @secret,
21
+ app_group_id: @app_group_id,
22
+ messages: message,
23
+ external_user_ids: user_ids,
24
+ segment_ids: [segment_id].compact
25
+ end
26
+
27
+ def schedule_message(date, message, segment_id, local_timezone=false)
28
+ post '/messages/schedule', company_secret: @secret,
29
+ segment_ids: [segment_id],
30
+ send_at: date,
31
+ deliver_in_local_timezone: local_timezone,
32
+ messages: message
33
+ end
34
+
35
+ private
36
+ def post(url, payload)
37
+ response = self.class.post(url, query: payload)
38
+ puts response.inspect
39
+ response['message'] == 'success'
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,3 @@
1
+ module Appboy
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,60 @@
1
+ require 'spec_helper'
2
+
3
+ describe Appboy::API do
4
+ let(:appboy) { Appboy::API.new('secret-key', 'app-group-id')}
5
+
6
+ context "#track" do
7
+ it "calls api" do
8
+ Appboy::API.should_receive(:post).with(
9
+ '/users/track',
10
+ query: {
11
+ company_secret: 'secret-key',
12
+ app_group_id: 'app-group-id',
13
+ attributes: :attributes,
14
+ events: :events,
15
+ purchases: :purchases
16
+ }
17
+ ).and_return('message' => 'success')
18
+
19
+ expect(appboy.track(:attributes, :events, :purchases)).to be_true
20
+ end
21
+
22
+ it "handles error"
23
+ end
24
+
25
+ context "#send_message" do
26
+ it "calls api" do
27
+ Appboy::API.should_receive(:post).with(
28
+ '/messages/send',
29
+ query: {
30
+ company_secret: 'secret-key',
31
+ app_group_id: 'app-group-id',
32
+ external_user_ids: :user_ids,
33
+ segment_ids: [:segment_id],
34
+ messages: :message
35
+ }
36
+ ).and_return('message' => 'success')
37
+
38
+ expect(appboy.send_message(:message, :user_ids, :segment_id)).to be_true
39
+ end
40
+ it "handles error"
41
+ end
42
+
43
+ context "#schedule_message" do
44
+ it "calls api" do
45
+ Appboy::API.should_receive(:post).with(
46
+ '/messages/schedule',
47
+ query: {
48
+ company_secret: 'secret-key',
49
+ segment_ids: [:segment_id],
50
+ send_at: :date,
51
+ deliver_in_local_timezone: :in_local_timezone,
52
+ messages: :message
53
+ }
54
+ ).and_return('message' => 'success')
55
+
56
+ expect(appboy.schedule_message(:date, :message, :segment_id, :in_local_timezone)).to be_true
57
+ end
58
+ it "handles error"
59
+ end
60
+ end
@@ -0,0 +1,8 @@
1
+ require 'bundler/setup'
2
+ Bundler.setup
3
+
4
+ require 'appboy'
5
+
6
+ RSpec.configure do |config|
7
+ # some (optional) config here
8
+ end
metadata ADDED
@@ -0,0 +1,115 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: appboy
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Josh Nussbaum
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
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: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Appboy wrapper
70
+ email:
71
+ - josh@godynamo.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - .gitignore
77
+ - Gemfile
78
+ - LICENSE.txt
79
+ - README.md
80
+ - Rakefile
81
+ - appboy.gemspec
82
+ - lib/appboy.rb
83
+ - lib/appboy/api.rb
84
+ - lib/appboy/version.rb
85
+ - spec/api_spec.rb
86
+ - spec/spec_helper.rb
87
+ homepage: http://appboy.com
88
+ licenses:
89
+ - MIT
90
+ metadata: {}
91
+ post_install_message:
92
+ rdoc_options: []
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - '>='
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - '>='
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ requirements: []
106
+ rubyforge_project:
107
+ rubygems_version: 2.0.3
108
+ signing_key:
109
+ specification_version: 4
110
+ summary: A wrapper for the Appboy REST API, track users/events/purchases, send & schedule
111
+ messages
112
+ test_files:
113
+ - spec/api_spec.rb
114
+ - spec/spec_helper.rb
115
+ has_rdoc: