appbaseio 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d711e934d6c9c63c8577df2ac0f581aecf12443e
4
+ data.tar.gz: 909612931ff35743e98c671715596626631721cc
5
+ SHA512:
6
+ metadata.gz: 3434d9fa9a90903b6e41db7f91fd2220132ef71b847e1a13fc8320def8b54f4f265a8492937bc005816f079a8b7bbbaed404e8e4b70c172272bf7ffc8f43a97b
7
+ data.tar.gz: 4b605530f2a255516da632b3cb865141a0460c7dea573e50d73d55e997d358fddf872412c5b2e58af45c1d15395fbf5715fcc397d7ddfc9798de117a34ca438c
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.0
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in appbaseio.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 David Ruan
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,31 @@
1
+ # Appbaseio
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'appbaseio'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install appbaseio
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/appbaseio/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ begin
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task :default => :spec
9
+ rescue LoadError
10
+ # no rspec available
11
+ end
12
+
data/appbaseio.gemspec ADDED
@@ -0,0 +1,33 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'appbaseio/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "appbaseio"
8
+ spec.version = Appbaseio::VERSION
9
+ spec.authors = ["David Ruan"]
10
+ spec.email = ["ruanwz@gmail.com"]
11
+ spec.summary = %q{appbaseio ruby rest client}
12
+ spec.description = %q{appbaseio ruby rest client}
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 "virtus", ">= 1.0"
22
+ spec.add_dependency "faraday", ">= 0.9"
23
+ spec.add_dependency "faraday_middleware", ">= 0.9.1"
24
+ spec.add_dependency "hashie", ">= 3.3.1"
25
+
26
+ spec.add_development_dependency "bundler", ">= 1.7"
27
+ spec.add_development_dependency "rake", ">= 10.0"
28
+ spec.add_development_dependency "rspec", ">= 3.0"
29
+ spec.add_development_dependency "pry", ">= 0.10"
30
+ spec.add_development_dependency "vcr", ">= 2.9"
31
+ spec.add_development_dependency "webmock", ">= 1.20"
32
+ spec.add_development_dependency "timecop", ">= 0.7"
33
+ end
@@ -0,0 +1,120 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: patch
5
+ uri: https://api.appbase.io/testapp/v2/test_api/iron/~properties
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"data":{"foo":"bar"}}'
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.1
12
+ Content-Type:
13
+ - application/json
14
+ Appbase-Secret:
15
+ - c1506ccb1db1ef61dc07f3546decf281
16
+ Accept-Encoding:
17
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
+ Accept:
19
+ - "*/*"
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Access-Control-Allow-Credentials:
26
+ - 'true'
27
+ Cache-Control:
28
+ - no-cache
29
+ Content-Type:
30
+ - application/json
31
+ Content-Length:
32
+ - '81'
33
+ Date:
34
+ - Fri, 06 Feb 2015 08:44:41 GMT
35
+ Connection:
36
+ - keep-alive
37
+ body:
38
+ encoding: UTF-8
39
+ string: '{"foo":"bar","timestamp":1423212281000,"_id":"test_api`54d47e8eb984f4bd156a7955"}'
40
+ http_version:
41
+ recorded_at: Fri, 06 Feb 2015 07:12:00 GMT
42
+ - request:
43
+ method: patch
44
+ uri: https://api.appbase.io/testapp/v2/test_api/ice/~properties
45
+ body:
46
+ encoding: UTF-8
47
+ string: '{"data":{"cat":"dog"}}'
48
+ headers:
49
+ User-Agent:
50
+ - Faraday v0.9.1
51
+ Content-Type:
52
+ - application/json
53
+ Appbase-Secret:
54
+ - c1506ccb1db1ef61dc07f3546decf281
55
+ Accept-Encoding:
56
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
57
+ Accept:
58
+ - "*/*"
59
+ response:
60
+ status:
61
+ code: 200
62
+ message: OK
63
+ headers:
64
+ Access-Control-Allow-Credentials:
65
+ - 'true'
66
+ Cache-Control:
67
+ - no-cache
68
+ Content-Type:
69
+ - application/json
70
+ Content-Length:
71
+ - '81'
72
+ Date:
73
+ - Fri, 06 Feb 2015 08:44:42 GMT
74
+ Connection:
75
+ - keep-alive
76
+ body:
77
+ encoding: UTF-8
78
+ string: '{"cat":"dog","timestamp":1423212282307,"_id":"test_api`54d47e92b984f4bd156a7957"}'
79
+ http_version:
80
+ recorded_at: Fri, 06 Feb 2015 07:12:00 GMT
81
+ - request:
82
+ method: patch
83
+ uri: https://api.appbase.io/testapp/v2/test_api/ice/~edges
84
+ body:
85
+ encoding: UTF-8
86
+ string: '{"data":{"anEdge":{"path":"test_api/iron"}}}'
87
+ headers:
88
+ User-Agent:
89
+ - Faraday v0.9.1
90
+ Content-Type:
91
+ - application/json
92
+ Appbase-Secret:
93
+ - c1506ccb1db1ef61dc07f3546decf281
94
+ Accept-Encoding:
95
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
96
+ Accept:
97
+ - "*/*"
98
+ response:
99
+ status:
100
+ code: 200
101
+ message: OK
102
+ headers:
103
+ Access-Control-Allow-Credentials:
104
+ - 'true'
105
+ Cache-Control:
106
+ - no-cache
107
+ Content-Type:
108
+ - application/json
109
+ Content-Length:
110
+ - '133'
111
+ Date:
112
+ - Fri, 06 Feb 2015 08:44:43 GMT
113
+ Connection:
114
+ - keep-alive
115
+ body:
116
+ encoding: UTF-8
117
+ string: '{"_id":"test_api`54d47e92b984f4bd156a7957","edges":{"anEdge":{"t_id":"test_api`54d47e8eb984f4bd156a7955","timestamp":1423212283618}}}'
118
+ http_version:
119
+ recorded_at: Fri, 06 Feb 2015 07:12:00 GMT
120
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,42 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: patch
5
+ uri: https://api.appbase.io/testapp/v2/test_api/abc/~properties
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"data":{"foo":"bar"}}'
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.1
12
+ Content-Type:
13
+ - application/json
14
+ Appbase-Secret:
15
+ - c1506ccb1db1ef61dc07f3546decf281
16
+ Accept-Encoding:
17
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
+ Accept:
19
+ - "*/*"
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Access-Control-Allow-Credentials:
26
+ - 'true'
27
+ Cache-Control:
28
+ - no-cache
29
+ Content-Type:
30
+ - application/json
31
+ Content-Length:
32
+ - '81'
33
+ Date:
34
+ - Fri, 06 Feb 2015 07:57:32 GMT
35
+ Connection:
36
+ - keep-alive
37
+ body:
38
+ encoding: UTF-8
39
+ string: '{"foo":"bar","timestamp":1423209452836,"_id":"test_api`54d4703cb984f4bd156a76ac"}'
40
+ http_version:
41
+ recorded_at: Fri, 06 Feb 2015 07:12:00 GMT
42
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,159 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: patch
5
+ uri: https://api.appbase.io/testapp/v2/test_api/iron/~properties
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"data":{"foo":"bar"}}'
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.1
12
+ Content-Type:
13
+ - application/json
14
+ Appbase-Secret:
15
+ - c1506ccb1db1ef61dc07f3546decf281
16
+ Accept-Encoding:
17
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
+ Accept:
19
+ - "*/*"
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Access-Control-Allow-Credentials:
26
+ - 'true'
27
+ Cache-Control:
28
+ - no-cache
29
+ Content-Type:
30
+ - application/json
31
+ Content-Length:
32
+ - '81'
33
+ Date:
34
+ - Fri, 06 Feb 2015 08:55:56 GMT
35
+ Connection:
36
+ - keep-alive
37
+ body:
38
+ encoding: UTF-8
39
+ string: '{"foo":"bar","timestamp":1423212956131,"_id":"test_api`54d47e8eb984f4bd156a7955"}'
40
+ http_version:
41
+ recorded_at: Fri, 06 Feb 2015 07:12:00 GMT
42
+ - request:
43
+ method: patch
44
+ uri: https://api.appbase.io/testapp/v2/test_api/ice/~properties
45
+ body:
46
+ encoding: UTF-8
47
+ string: '{"data":{"cat":"dog"}}'
48
+ headers:
49
+ User-Agent:
50
+ - Faraday v0.9.1
51
+ Content-Type:
52
+ - application/json
53
+ Appbase-Secret:
54
+ - c1506ccb1db1ef61dc07f3546decf281
55
+ Accept-Encoding:
56
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
57
+ Accept:
58
+ - "*/*"
59
+ response:
60
+ status:
61
+ code: 200
62
+ message: OK
63
+ headers:
64
+ Access-Control-Allow-Credentials:
65
+ - 'true'
66
+ Cache-Control:
67
+ - no-cache
68
+ Content-Type:
69
+ - application/json
70
+ Content-Length:
71
+ - '81'
72
+ Date:
73
+ - Fri, 06 Feb 2015 08:55:58 GMT
74
+ Connection:
75
+ - keep-alive
76
+ body:
77
+ encoding: UTF-8
78
+ string: '{"cat":"dog","timestamp":1423212958717,"_id":"test_api`54d47e92b984f4bd156a7957"}'
79
+ http_version:
80
+ recorded_at: Fri, 06 Feb 2015 07:12:00 GMT
81
+ - request:
82
+ method: patch
83
+ uri: https://api.appbase.io/testapp/v2/test_api/ice/~edges
84
+ body:
85
+ encoding: UTF-8
86
+ string: '{"data":{"anEdge":{"path":"test_api/iron"}}}'
87
+ headers:
88
+ User-Agent:
89
+ - Faraday v0.9.1
90
+ Content-Type:
91
+ - application/json
92
+ Appbase-Secret:
93
+ - c1506ccb1db1ef61dc07f3546decf281
94
+ Accept-Encoding:
95
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
96
+ Accept:
97
+ - "*/*"
98
+ response:
99
+ status:
100
+ code: 200
101
+ message: OK
102
+ headers:
103
+ Access-Control-Allow-Credentials:
104
+ - 'true'
105
+ Cache-Control:
106
+ - no-cache
107
+ Content-Type:
108
+ - application/json
109
+ Content-Length:
110
+ - '133'
111
+ Date:
112
+ - Fri, 06 Feb 2015 08:56:00 GMT
113
+ Connection:
114
+ - keep-alive
115
+ body:
116
+ encoding: UTF-8
117
+ string: '{"_id":"test_api`54d47e92b984f4bd156a7957","edges":{"anEdge":{"t_id":"test_api`54d47e8eb984f4bd156a7955","timestamp":1423212960068}}}'
118
+ http_version:
119
+ recorded_at: Fri, 06 Feb 2015 07:12:00 GMT
120
+ - request:
121
+ method: delete
122
+ uri: https://api.appbase.io/testapp/v2/test_api/ice/~edges?data%5B%5D=anEdge
123
+ body:
124
+ encoding: UTF-8
125
+ string: '{"data":["anEdge"]}'
126
+ headers:
127
+ User-Agent:
128
+ - Faraday v0.9.1
129
+ Content-Type:
130
+ - application/json
131
+ Appbase-Secret:
132
+ - c1506ccb1db1ef61dc07f3546decf281
133
+ Accept-Encoding:
134
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
135
+ Accept:
136
+ - "*/*"
137
+ response:
138
+ status:
139
+ code: 200
140
+ message: OK
141
+ headers:
142
+ Access-Control-Allow-Credentials:
143
+ - 'true'
144
+ Cache-Control:
145
+ - no-cache
146
+ Content-Type:
147
+ - application/json
148
+ Content-Length:
149
+ - '100'
150
+ Date:
151
+ - Fri, 06 Feb 2015 08:56:01 GMT
152
+ Connection:
153
+ - keep-alive
154
+ body:
155
+ encoding: UTF-8
156
+ string: '{"_id":"test_api`54d47e92b984f4bd156a7957","edges":{"anEdge":{"timestamp":1423212961747,"t_id":""}}}'
157
+ http_version:
158
+ recorded_at: Fri, 06 Feb 2015 07:12:00 GMT
159
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,81 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: patch
5
+ uri: https://api.appbase.io/testapp/v2/test_api/abc/~properties
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"data":{"foo":"bar"}}'
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.1
12
+ Content-Type:
13
+ - application/json
14
+ Appbase-Secret:
15
+ - c1506ccb1db1ef61dc07f3546decf281
16
+ Accept-Encoding:
17
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
+ Accept:
19
+ - "*/*"
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Access-Control-Allow-Credentials:
26
+ - 'true'
27
+ Cache-Control:
28
+ - no-cache
29
+ Content-Type:
30
+ - application/json
31
+ Content-Length:
32
+ - '81'
33
+ Date:
34
+ - Fri, 06 Feb 2015 08:34:52 GMT
35
+ Connection:
36
+ - keep-alive
37
+ body:
38
+ encoding: UTF-8
39
+ string: '{"foo":"bar","timestamp":1423211692473,"_id":"test_api`54d4703cb984f4bd156a76ac"}'
40
+ http_version:
41
+ recorded_at: Fri, 06 Feb 2015 07:12:00 GMT
42
+ - request:
43
+ method: delete
44
+ uri: https://api.appbase.io/testapp/v2/test_api/abc/~properties?data%5B%5D=foo
45
+ body:
46
+ encoding: UTF-8
47
+ string: '{"data":["foo"]}'
48
+ headers:
49
+ User-Agent:
50
+ - Faraday v0.9.1
51
+ Content-Type:
52
+ - application/json
53
+ Appbase-Secret:
54
+ - c1506ccb1db1ef61dc07f3546decf281
55
+ Accept-Encoding:
56
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
57
+ Accept:
58
+ - "*/*"
59
+ response:
60
+ status:
61
+ code: 200
62
+ message: OK
63
+ headers:
64
+ Access-Control-Allow-Credentials:
65
+ - 'true'
66
+ Cache-Control:
67
+ - no-cache
68
+ Content-Type:
69
+ - application/json
70
+ Content-Length:
71
+ - '78'
72
+ Date:
73
+ - Fri, 06 Feb 2015 08:34:56 GMT
74
+ Connection:
75
+ - keep-alive
76
+ body:
77
+ encoding: UTF-8
78
+ string: '{"foo":"","_id":"test_api`54d4703cb984f4bd156a76ac","timestamp":1423211696726}'
79
+ http_version:
80
+ recorded_at: Fri, 06 Feb 2015 07:12:00 GMT
81
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,42 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.appbase.io/testapp/v2/test_api/~list
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"data":null}'
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.1
12
+ Content-Type:
13
+ - application/json
14
+ Appbase-Secret:
15
+ - c1506ccb1db1ef61dc07f3546decf281
16
+ Accept-Encoding:
17
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
+ Accept:
19
+ - "*/*"
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Access-Control-Allow-Credentials:
26
+ - 'true'
27
+ Cache-Control:
28
+ - no-cache
29
+ Content-Type:
30
+ - application/json
31
+ Content-Length:
32
+ - '88'
33
+ Date:
34
+ - Fri, 06 Feb 2015 07:57:31 GMT
35
+ Connection:
36
+ - keep-alive
37
+ body:
38
+ encoding: UTF-8
39
+ string: '[{"_id":"54d4703cb984f4bd156a76ac","timestamp":1423209005094,"rootPath":"test_api/abc"}]'
40
+ http_version:
41
+ recorded_at: Fri, 06 Feb 2015 07:12:00 GMT
42
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,159 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: patch
5
+ uri: https://api.appbase.io/testapp/v2/test_api/iron/~properties
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"data":{"foo":"bar"}}'
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.1
12
+ Content-Type:
13
+ - application/json
14
+ Appbase-Secret:
15
+ - c1506ccb1db1ef61dc07f3546decf281
16
+ Accept-Encoding:
17
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
+ Accept:
19
+ - "*/*"
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Access-Control-Allow-Credentials:
26
+ - 'true'
27
+ Cache-Control:
28
+ - no-cache
29
+ Content-Type:
30
+ - application/json
31
+ Content-Length:
32
+ - '81'
33
+ Date:
34
+ - Fri, 06 Feb 2015 08:55:50 GMT
35
+ Connection:
36
+ - keep-alive
37
+ body:
38
+ encoding: UTF-8
39
+ string: '{"foo":"bar","timestamp":1423212950648,"_id":"test_api`54d47e8eb984f4bd156a7955"}'
40
+ http_version:
41
+ recorded_at: Fri, 06 Feb 2015 07:12:00 GMT
42
+ - request:
43
+ method: patch
44
+ uri: https://api.appbase.io/testapp/v2/test_api/ice/~properties
45
+ body:
46
+ encoding: UTF-8
47
+ string: '{"data":{"cat":"dog"}}'
48
+ headers:
49
+ User-Agent:
50
+ - Faraday v0.9.1
51
+ Content-Type:
52
+ - application/json
53
+ Appbase-Secret:
54
+ - c1506ccb1db1ef61dc07f3546decf281
55
+ Accept-Encoding:
56
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
57
+ Accept:
58
+ - "*/*"
59
+ response:
60
+ status:
61
+ code: 200
62
+ message: OK
63
+ headers:
64
+ Access-Control-Allow-Credentials:
65
+ - 'true'
66
+ Cache-Control:
67
+ - no-cache
68
+ Content-Type:
69
+ - application/json
70
+ Content-Length:
71
+ - '81'
72
+ Date:
73
+ - Fri, 06 Feb 2015 08:55:52 GMT
74
+ Connection:
75
+ - keep-alive
76
+ body:
77
+ encoding: UTF-8
78
+ string: '{"cat":"dog","timestamp":1423212952007,"_id":"test_api`54d47e92b984f4bd156a7957"}'
79
+ http_version:
80
+ recorded_at: Fri, 06 Feb 2015 07:12:00 GMT
81
+ - request:
82
+ method: patch
83
+ uri: https://api.appbase.io/testapp/v2/test_api/ice/~edges
84
+ body:
85
+ encoding: UTF-8
86
+ string: '{"data":{"anEdge":{"path":"test_api/iron"}}}'
87
+ headers:
88
+ User-Agent:
89
+ - Faraday v0.9.1
90
+ Content-Type:
91
+ - application/json
92
+ Appbase-Secret:
93
+ - c1506ccb1db1ef61dc07f3546decf281
94
+ Accept-Encoding:
95
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
96
+ Accept:
97
+ - "*/*"
98
+ response:
99
+ status:
100
+ code: 200
101
+ message: OK
102
+ headers:
103
+ Access-Control-Allow-Credentials:
104
+ - 'true'
105
+ Cache-Control:
106
+ - no-cache
107
+ Content-Type:
108
+ - application/json
109
+ Content-Length:
110
+ - '133'
111
+ Date:
112
+ - Fri, 06 Feb 2015 08:55:53 GMT
113
+ Connection:
114
+ - keep-alive
115
+ body:
116
+ encoding: UTF-8
117
+ string: '{"_id":"test_api`54d47e92b984f4bd156a7957","edges":{"anEdge":{"t_id":"test_api`54d47e8eb984f4bd156a7955","timestamp":1423212953354}}}'
118
+ http_version:
119
+ recorded_at: Fri, 06 Feb 2015 07:12:00 GMT
120
+ - request:
121
+ method: post
122
+ uri: https://api.appbase.io/testapp/v2/test_api/ice/~edges
123
+ body:
124
+ encoding: UTF-8
125
+ string: '{"filters":{}}'
126
+ headers:
127
+ User-Agent:
128
+ - Faraday v0.9.1
129
+ Content-Type:
130
+ - application/json
131
+ Appbase-Secret:
132
+ - c1506ccb1db1ef61dc07f3546decf281
133
+ Accept-Encoding:
134
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
135
+ Accept:
136
+ - "*/*"
137
+ response:
138
+ status:
139
+ code: 200
140
+ message: OK
141
+ headers:
142
+ Access-Control-Allow-Credentials:
143
+ - 'true'
144
+ Cache-Control:
145
+ - no-cache
146
+ Content-Type:
147
+ - application/json
148
+ Content-Length:
149
+ - '149'
150
+ Date:
151
+ - Fri, 06 Feb 2015 08:55:54 GMT
152
+ Connection:
153
+ - keep-alive
154
+ body:
155
+ encoding: UTF-8
156
+ string: '{"edges":{"anEdge":{"t_id":"test_api`54d47e8eb984f4bd156a7955","timestamp":1423212953354}},"optype":"RETR","_id":"test_api`54d47e92b984f4bd156a7957"}'
157
+ http_version:
158
+ recorded_at: Fri, 06 Feb 2015 07:12:00 GMT
159
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,81 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: patch
5
+ uri: https://api.appbase.io/testapp/v2/test_api/abc/~properties
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"data":{"foo":"bar"}}'
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.1
12
+ Content-Type:
13
+ - application/json
14
+ Appbase-Secret:
15
+ - c1506ccb1db1ef61dc07f3546decf281
16
+ Accept-Encoding:
17
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
+ Accept:
19
+ - "*/*"
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Access-Control-Allow-Credentials:
26
+ - 'true'
27
+ Cache-Control:
28
+ - no-cache
29
+ Content-Type:
30
+ - application/json
31
+ Content-Length:
32
+ - '81'
33
+ Date:
34
+ - Fri, 06 Feb 2015 08:17:22 GMT
35
+ Connection:
36
+ - keep-alive
37
+ body:
38
+ encoding: UTF-8
39
+ string: '{"foo":"bar","timestamp":1423210642363,"_id":"test_api`54d4703cb984f4bd156a76ac"}'
40
+ http_version:
41
+ recorded_at: Fri, 06 Feb 2015 07:12:00 GMT
42
+ - request:
43
+ method: post
44
+ uri: https://api.appbase.io/testapp/v2/test_api/abc/~properties
45
+ body:
46
+ encoding: UTF-8
47
+ string: '{"all":true}'
48
+ headers:
49
+ User-Agent:
50
+ - Faraday v0.9.1
51
+ Content-Type:
52
+ - application/json
53
+ Appbase-Secret:
54
+ - c1506ccb1db1ef61dc07f3546decf281
55
+ Accept-Encoding:
56
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
57
+ Accept:
58
+ - "*/*"
59
+ response:
60
+ status:
61
+ code: 200
62
+ message: OK
63
+ headers:
64
+ Access-Control-Allow-Credentials:
65
+ - 'true'
66
+ Cache-Control:
67
+ - no-cache
68
+ Content-Type:
69
+ - application/json
70
+ Content-Length:
71
+ - '134'
72
+ Date:
73
+ - Fri, 06 Feb 2015 08:17:23 GMT
74
+ Connection:
75
+ - keep-alive
76
+ body:
77
+ encoding: UTF-8
78
+ string: '{"vertex":{"_id":"test_api`54d4703cb984f4bd156a76ac","timestamp":1423210642363,"rootPath":"test_api/abc","foo":"bar"},"optype":"RETR"}'
79
+ http_version:
80
+ recorded_at: Fri, 06 Feb 2015 07:12:00 GMT
81
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,31 @@
1
+ module FaradayMiddleware
2
+ # Request middleware that encodes the body as JSON.
3
+ #
4
+ # Processes only requests with matching Content-type or those without a type.
5
+ # If a request doesn't have a type but has a body, it sets the Content-type
6
+ # to JSON MIME-type.
7
+ #
8
+ # Doesn't try to encode bodies that already are in string form.
9
+ class Auth < Faraday::Middleware
10
+
11
+ AUTH_HEADER = 'Authorization'.freeze
12
+ def initialize(app, token = nil, options = {})
13
+ super(app)
14
+ options, token = token, nil if token.is_a? Hash
15
+ @token = token && token.to_s
16
+ @auth_header = options.fetch(:auth_header, AUTH_HEADER).to_s
17
+ raise ArgumentError, ":auth_header can't be blank" if @auth_header.empty?
18
+ end
19
+
20
+ def call(env)
21
+ env[:request_headers][@auth_header] ||= @token
22
+ @app.call env
23
+ end
24
+ end
25
+
26
+ end
27
+
28
+ if Faraday::Middleware.respond_to? :register_middleware
29
+ Faraday::Request.register_middleware \
30
+ :api_header_auth => lambda { FaradayMiddleware::Auth }
31
+ end
@@ -0,0 +1,72 @@
1
+ require 'virtus'
2
+ require 'faraday'
3
+ require 'faraday_middleware'
4
+ require 'json'
5
+ require 'pry'
6
+ require 'appbaseio/auth_middleware'
7
+
8
+ module Appbaseio
9
+
10
+ HTTP_METHOD_MAP = {
11
+ 'list' => :post,
12
+ 'create' => :patch,
13
+ 'read' => :post,
14
+ 'update' => :patch,
15
+ 'delete' => :delete,
16
+ 'properties' => :patch
17
+ }
18
+ TARGETS = %w{list properties edges}
19
+ class Client
20
+ include Virtus.model
21
+ attribute :server_host, String, default: 'api.appbase.io'
22
+ attribute :app_name, String
23
+ attribute :api_version, String, default: 'v2'
24
+ attribute :namespace, String
25
+ attribute :app_secret, String
26
+ def initialize(options)
27
+ super
28
+ end
29
+
30
+ def common_path
31
+ "/#{app_name}/#{api_version}/#{namespace}"
32
+ end
33
+
34
+ def rest_client
35
+ Faraday.new(url: "https://"+server_host) do |faraday|
36
+ #faraday.request :url_encoded
37
+ faraday.response :logger
38
+ faraday.request :json
39
+ faraday.response :json
40
+ faraday.response :mashify
41
+ faraday.request :api_header_auth, app_secret, auth_header: 'Appbase-Secret'
42
+ faraday.adapter Faraday.default_adapter
43
+ end
44
+ end
45
+
46
+ def path(target, operation, vertex)
47
+ [common_path, vertex, "~#{target}"].compact.join '/'
48
+ end
49
+
50
+ def method_missing(m, *args, &block)
51
+ operation, target = m.to_s.split('_')
52
+ return super unless HTTP_METHOD_MAP.keys.include? operation
53
+ return super unless TARGETS.include? target
54
+ options = args[0] || {}
55
+ vertex = options[:vertex] || nil
56
+ data = {data: options[:data]}
57
+ data = {all: true} if operation == 'read' and target == 'properties'
58
+ data = {filters: {}} if operation == 'read' and target == 'edges'
59
+
60
+ method = HTTP_METHOD_MAP[operation]
61
+ if data
62
+ resp = rest_client.send method, path(target, operation, vertex), data do |req|
63
+ req.body = data.to_json if operation == 'delete'
64
+ end
65
+ else
66
+ resp = rest_client.send method, path(target, operation, vertex) do |req|
67
+ end
68
+ end
69
+ resp
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,3 @@
1
+ module Appbaseio
2
+ VERSION = "0.0.1"
3
+ end
data/lib/appbaseio.rb ADDED
@@ -0,0 +1,6 @@
1
+ require "appbaseio/client"
2
+ require "appbaseio/version"
3
+
4
+ module Appbaseio
5
+ # Your code goes here...
6
+ end
@@ -0,0 +1,98 @@
1
+ require 'spec_helper'
2
+ require 'vcr_helper'
3
+ require 'timecop'
4
+ describe Appbaseio::Client do
5
+ before do
6
+ Timecop.freeze(Time.utc(2015,2,6,7,12))
7
+ end
8
+ after do
9
+ Timecop.return
10
+ end
11
+ options = {
12
+ server_host: 'api.appbase.io',
13
+ app_name: 'testapp',
14
+ api_version: 'v2',
15
+ namespace: 'test_api',
16
+ app_secret: 'c1506ccb1db1ef61dc07f3546decf281'
17
+ }
18
+ subject {Appbaseio::Client.new(options)}
19
+ it "accept parameters" do
20
+ expect {subject}.to_not raise_error
21
+ end
22
+ it "can access the initialized parameters" do
23
+ expect(subject.server_host).to eq options[:server_host]
24
+ end
25
+ it "list all vertex in the namespace" do
26
+
27
+ VCR.use_cassette('list all vertex in a namespace') do
28
+ resp = subject.list_list
29
+ expect(resp.status).to be 200
30
+ expect(resp.body).to be_a Array
31
+ end
32
+ end
33
+
34
+ it "search vertices" do
35
+
36
+ end
37
+
38
+ it "create vertex" do
39
+ VCR.use_cassette('create vertex') do
40
+ resp = subject.create_properties vertex: 'abc', data: {foo: 'bar'}
41
+ expect(resp.status).to be 200
42
+ expect(resp.body).to be_a Hash
43
+ expect(resp.body).to include "foo" => 'bar'
44
+ end
45
+ end
46
+
47
+ it "read vertex" do
48
+ VCR.use_cassette('read vertex') do
49
+ subject.create_properties vertex: 'abc', data: {foo: 'bar'}
50
+ resp = subject.read_properties vertex: 'abc'
51
+
52
+ expect(resp.status).to be 200
53
+ expect(resp.body).to be_a Hash
54
+ expect(resp.body["vertex"]).to include "foo" => 'bar'
55
+ end
56
+ end
57
+
58
+ it "delete vertex" do
59
+ VCR.use_cassette('delete vertex') do
60
+ subject.create_properties vertex: 'abc', data: {foo: 'bar'}
61
+ resp = subject.delete_properties vertex: 'abc', data: ["foo"]
62
+
63
+ expect(resp.status).to be 200
64
+ end
65
+ end
66
+
67
+ it "create edges" do
68
+ VCR.use_cassette('create edges') do
69
+ subject.create_properties vertex: 'iron', data: {foo: 'bar'}
70
+ subject.create_properties vertex: 'ice', data: {cat: 'dog'}
71
+
72
+ resp = subject.create_edges vertex: 'ice', data: {anEdge: {path: "test_api/iron"}}
73
+ expect(resp.status).to be 200
74
+ end
75
+ end
76
+
77
+ it "read edges" do
78
+ VCR.use_cassette('read edges') do
79
+ subject.create_properties vertex: 'iron', data: {foo: 'bar'}
80
+ subject.create_properties vertex: 'ice', data: {cat: 'dog'}
81
+ subject.create_edges vertex: 'ice', data: {anEdge: {path: "test_api/iron"}}
82
+
83
+ resp = subject.read_edges vertex: 'ice'
84
+ expect(resp.status).to be 200
85
+ end
86
+ end
87
+
88
+ it "delete edges" do
89
+ VCR.use_cassette('delete edges') do
90
+ subject.create_properties vertex: 'iron', data: {foo: 'bar'}
91
+ subject.create_properties vertex: 'ice', data: {cat: 'dog'}
92
+ subject.create_edges vertex: 'ice', data: {anEdge: {path: "test_api/iron"}}
93
+
94
+ resp = subject.delete_edges vertex: 'ice', data: ["anEdge"]
95
+ expect(resp.status).to be 200
96
+ end
97
+ end
98
+ end
@@ -0,0 +1 @@
1
+ require 'appbaseio'
@@ -0,0 +1,7 @@
1
+ require 'vcr'
2
+ require 'webmock'
3
+ VCR.configure do |c|
4
+ c.cassette_library_dir = 'fixtures/vcr_cassettes'
5
+ c.hook_into :webmock # or :fakeweb
6
+ c.allow_http_connections_when_no_cassette = true
7
+ end
metadata ADDED
@@ -0,0 +1,223 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: appbaseio
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - David Ruan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: virtus
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: faraday
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0.9'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0.9'
41
+ - !ruby/object:Gem::Dependency
42
+ name: faraday_middleware
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 0.9.1
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 0.9.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: hashie
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 3.3.1
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 3.3.1
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '1.7'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '1.7'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '10.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '10.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '3.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '3.0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: pry
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0.10'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0.10'
125
+ - !ruby/object:Gem::Dependency
126
+ name: vcr
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '2.9'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '2.9'
139
+ - !ruby/object:Gem::Dependency
140
+ name: webmock
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '1.20'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '1.20'
153
+ - !ruby/object:Gem::Dependency
154
+ name: timecop
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0.7'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0.7'
167
+ description: appbaseio ruby rest client
168
+ email:
169
+ - ruanwz@gmail.com
170
+ executables: []
171
+ extensions: []
172
+ extra_rdoc_files: []
173
+ files:
174
+ - ".gitignore"
175
+ - ".travis.yml"
176
+ - Gemfile
177
+ - LICENSE.txt
178
+ - README.md
179
+ - Rakefile
180
+ - appbaseio.gemspec
181
+ - fixtures/vcr_cassettes/create_edges.yml
182
+ - fixtures/vcr_cassettes/create_vertex.yml
183
+ - fixtures/vcr_cassettes/delete_edges.yml
184
+ - fixtures/vcr_cassettes/delete_vertex.yml
185
+ - fixtures/vcr_cassettes/list_all_vertex_in_a_namespace.yml
186
+ - fixtures/vcr_cassettes/read_edges.yml
187
+ - fixtures/vcr_cassettes/read_vertex.yml
188
+ - lib/appbaseio.rb
189
+ - lib/appbaseio/auth_middleware.rb
190
+ - lib/appbaseio/client.rb
191
+ - lib/appbaseio/version.rb
192
+ - spec/appbaseio/client_spec.rb
193
+ - spec/spec_helper.rb
194
+ - spec/vcr_helper.rb
195
+ homepage: ''
196
+ licenses:
197
+ - MIT
198
+ metadata: {}
199
+ post_install_message:
200
+ rdoc_options: []
201
+ require_paths:
202
+ - lib
203
+ required_ruby_version: !ruby/object:Gem::Requirement
204
+ requirements:
205
+ - - ">="
206
+ - !ruby/object:Gem::Version
207
+ version: '0'
208
+ required_rubygems_version: !ruby/object:Gem::Requirement
209
+ requirements:
210
+ - - ">="
211
+ - !ruby/object:Gem::Version
212
+ version: '0'
213
+ requirements: []
214
+ rubyforge_project:
215
+ rubygems_version: 2.2.2
216
+ signing_key:
217
+ specification_version: 4
218
+ summary: appbaseio ruby rest client
219
+ test_files:
220
+ - spec/appbaseio/client_spec.rb
221
+ - spec/spec_helper.rb
222
+ - spec/vcr_helper.rb
223
+ has_rdoc: