waitlisted 0.1.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 +9 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +65 -0
- data/Rakefile +1 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/waitlisted.rb +16 -0
- data/lib/waitlisted/client.rb +17 -0
- data/lib/waitlisted/configuration/base.rb +24 -0
- data/lib/waitlisted/errors.rb +4 -0
- data/lib/waitlisted/models/base.rb +45 -0
- data/lib/waitlisted/models/reservation.rb +26 -0
- data/lib/waitlisted/version.rb +3 -0
- data/waitlisted.gemspec +34 -0
- metadata +160 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4bb20a0780512a30d0bf8de179cee6d4b6db6e35
|
4
|
+
data.tar.gz: b73b39ca09ff47ed4591bf9afc16cfd142df028c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6e265fb6641607acdc92b8a52b133fe4083181178866a338305efbb57867003ecbf97a63ad57085c2b423af83ff4736bc0a35cc90410d7d8486ca07a1f2510cd
|
7
|
+
data.tar.gz: d85d044489b7194c6c5b26cb9fea75a2859107c24c0d1e4fa2d7f7919387217e38dd4f4c818506fff74f4aa186c1ebe9b98ae453da51e65e689b04ba6823a64f
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Justin McNally
|
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,65 @@
|
|
1
|
+
# Waitlisted
|
2
|
+
|
3
|
+
Waitlisted is an easy way to manage subscribers before you launch your product. Great for beta signups and new user mangement.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'waitlisted', github: "waitlisted/waitlisted-ruby"
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install waitlisted
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Setup Waitlisted to know the URL to use to manage your reservations:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
Waitlisted.configure do |config|
|
27
|
+
config.url = "https://mysite.app.waitlisted.co/"
|
28
|
+
end
|
29
|
+
```
|
30
|
+
|
31
|
+
Or you can set the url via an environment variable
|
32
|
+
|
33
|
+
```
|
34
|
+
WAITLISTED_URL: "https://mysite.app.waitlisted.co/"
|
35
|
+
```
|
36
|
+
|
37
|
+
|
38
|
+
Then create a reservation:
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
@reservation = Waitlisted::Reservation.create(email: 'test@myemail.com')
|
42
|
+
# => #<Waitlisted::Reservation:0x00000102980258 @id="dfc56acbc7e0b249866d49fc27581816", @uuid="dfc56acbc7e0b249866d49fc27581816", @affiliate="71c1e7b5cdfd", @email="test@myemail.com", @name=nil, @position=1, @meta={"total"=>1}>
|
43
|
+
```
|
44
|
+
|
45
|
+
You can also query the api for an exisiting reservation:
|
46
|
+
```ruby
|
47
|
+
Waitlisted::Reservation.find(email: "test@test.com")
|
48
|
+
# => #<Waitlisted::Reservation:0x007fbecac2c3c0 @id="f12b29bd8a7ca8cfae639539e8507bad", @uuid="f12b29bd8a7ca8cfae639539e8507bad", @affiliate="fd2c7e6802c9", @email="test@test.com", @name=nil, @position=1, @meta={"total"=>1}>
|
49
|
+
```
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
## Development
|
54
|
+
|
55
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
56
|
+
|
57
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
58
|
+
|
59
|
+
## Contributing
|
60
|
+
|
61
|
+
1. Fork it ( https://github.com/[my-github-username]/waitlisted_ruby/fork )
|
62
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
63
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
64
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
65
|
+
5. Create a new Pull Request
|
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 "waitlisted_ruby"
|
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
data/lib/waitlisted.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require "ostruct"
|
2
|
+
require "faraday"
|
3
|
+
require "waitlisted/version"
|
4
|
+
require "waitlisted/configuration/base"
|
5
|
+
require "waitlisted/errors"
|
6
|
+
|
7
|
+
require "waitlisted/client"
|
8
|
+
|
9
|
+
require "waitlisted/models/base"
|
10
|
+
require "waitlisted/models/reservation"
|
11
|
+
|
12
|
+
|
13
|
+
module Waitlisted
|
14
|
+
extend Configuration::Base
|
15
|
+
include Client
|
16
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Waitlisted
|
2
|
+
module Client
|
3
|
+
def client
|
4
|
+
raise Waitlisted::ConfigurationError,
|
5
|
+
"
|
6
|
+
You must specify a waitlisted url in
|
7
|
+
the configuration block.
|
8
|
+
(http://mysite.app.waitlisted.co)
|
9
|
+
" if Waitlisted.configuration.url.nil?
|
10
|
+
Faraday.new(:url => Waitlisted.configuration.url) do |faraday|
|
11
|
+
faraday.request :url_encoded # form-encode POST params
|
12
|
+
# faraday.response :logger # log requests to STDOUT
|
13
|
+
faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Waitlisted
|
2
|
+
module Configuration
|
3
|
+
module Base
|
4
|
+
def reset
|
5
|
+
if ENV['WAITLISTED_URL']
|
6
|
+
@@configuration = OpenStruct.new(url: "#{ENV['WAITLISTED_URL']}")
|
7
|
+
else
|
8
|
+
@@configuration = OpenStruct.new
|
9
|
+
end
|
10
|
+
end
|
11
|
+
def configure(&block)
|
12
|
+
yield configuration
|
13
|
+
end
|
14
|
+
|
15
|
+
def configuration
|
16
|
+
@@configuration
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.extended(base)
|
20
|
+
base.reset
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Waitlisted
|
2
|
+
class Base
|
3
|
+
class << self
|
4
|
+
def create(params)
|
5
|
+
resp = post(api_base("/#{resource_name}"), params)
|
6
|
+
parse_response(resp.body)
|
7
|
+
end
|
8
|
+
|
9
|
+
def show(params)
|
10
|
+
resp = get(api_base("/#{resource_name}"), params)
|
11
|
+
parse_response(resp.body)
|
12
|
+
end
|
13
|
+
|
14
|
+
alias :find :show
|
15
|
+
|
16
|
+
protected
|
17
|
+
def post(url, params)
|
18
|
+
data = {}
|
19
|
+
data[resource_name] = params
|
20
|
+
Waitlisted.client.post(url, data)
|
21
|
+
end
|
22
|
+
|
23
|
+
def get(url, params)
|
24
|
+
Waitlisted.client.get(url, params)
|
25
|
+
end
|
26
|
+
|
27
|
+
def parse_response(resp)
|
28
|
+
hash = JSON.parse(resp)
|
29
|
+
raise_error(hash['errors']) if hash['errors']
|
30
|
+
response = self.new(hash)
|
31
|
+
response
|
32
|
+
end
|
33
|
+
|
34
|
+
def api_base(route)
|
35
|
+
"/api/v1#{route}"
|
36
|
+
end
|
37
|
+
|
38
|
+
def raise_error(errors)
|
39
|
+
errors.each do |field, message|
|
40
|
+
raise Waitlisted::ValidationError, [field, message].join(' ')
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Waitlisted
|
2
|
+
class Reservation < Base
|
3
|
+
class << self
|
4
|
+
def resource_name_plural
|
5
|
+
"reservations"
|
6
|
+
end
|
7
|
+
def resource_name
|
8
|
+
"reservation"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
attr_accessor :id, :uuid, :affiliate, :email, :name, :position, :meta
|
13
|
+
|
14
|
+
def initialize(params)
|
15
|
+
rparams = params["reservation"]
|
16
|
+
self.id = rparams["id"]
|
17
|
+
self.uuid = rparams["uuid"]
|
18
|
+
self.affiliate = rparams["affiliate"]
|
19
|
+
self.email = rparams["email"]
|
20
|
+
self.name = rparams["name"]
|
21
|
+
self.position = rparams["position"]
|
22
|
+
self.meta = params["meta"]
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
data/waitlisted.gemspec
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'waitlisted/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "waitlisted"
|
8
|
+
spec.version = Waitlisted::VERSION
|
9
|
+
spec.authors = ["Justin McNally"]
|
10
|
+
spec.email = ["justin@waitlisted.co"]
|
11
|
+
|
12
|
+
spec.summary = %q{Use the waitlisted api from ruby}
|
13
|
+
spec.description = %q{Easily integrate the waitlisted api from ruby.}
|
14
|
+
spec.homepage = "https://waitlisted.co"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
18
|
+
# delete this section to allow pushing this gem to any host.
|
19
|
+
|
20
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
21
|
+
spec.bindir = "exe"
|
22
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
|
+
spec.require_paths = ["lib"]
|
24
|
+
|
25
|
+
|
26
|
+
spec.add_dependency "faraday"
|
27
|
+
spec.add_dependency "json"
|
28
|
+
|
29
|
+
spec.add_development_dependency "bundler", "~> 1.9"
|
30
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
31
|
+
spec.add_development_dependency "rspec"
|
32
|
+
spec.add_development_dependency "vcr"
|
33
|
+
spec.add_development_dependency "webmock"
|
34
|
+
end
|
metadata
ADDED
@@ -0,0 +1,160 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: waitlisted
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Justin McNally
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-08-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
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: json
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.9'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.9'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: vcr
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: webmock
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: Easily integrate the waitlisted api from ruby.
|
112
|
+
email:
|
113
|
+
- justin@waitlisted.co
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- ".gitignore"
|
119
|
+
- ".rspec"
|
120
|
+
- ".travis.yml"
|
121
|
+
- Gemfile
|
122
|
+
- LICENSE.txt
|
123
|
+
- README.md
|
124
|
+
- Rakefile
|
125
|
+
- bin/console
|
126
|
+
- bin/setup
|
127
|
+
- lib/waitlisted.rb
|
128
|
+
- lib/waitlisted/client.rb
|
129
|
+
- lib/waitlisted/configuration/base.rb
|
130
|
+
- lib/waitlisted/errors.rb
|
131
|
+
- lib/waitlisted/models/base.rb
|
132
|
+
- lib/waitlisted/models/reservation.rb
|
133
|
+
- lib/waitlisted/version.rb
|
134
|
+
- waitlisted.gemspec
|
135
|
+
homepage: https://waitlisted.co
|
136
|
+
licenses:
|
137
|
+
- MIT
|
138
|
+
metadata: {}
|
139
|
+
post_install_message:
|
140
|
+
rdoc_options: []
|
141
|
+
require_paths:
|
142
|
+
- lib
|
143
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - ">="
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '0'
|
148
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
requirements: []
|
154
|
+
rubyforge_project:
|
155
|
+
rubygems_version: 2.2.2
|
156
|
+
signing_key:
|
157
|
+
specification_version: 4
|
158
|
+
summary: Use the waitlisted api from ruby
|
159
|
+
test_files: []
|
160
|
+
has_rdoc:
|