the86-client 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/the86-client.rb +1 -0
- data/lib/the86-client/access_token.rb +16 -0
- data/lib/the86-client/connection.rb +10 -1
- data/lib/the86-client/resource.rb +3 -1
- data/lib/the86-client/user.rb +2 -0
- data/lib/the86-client/version.rb +1 -1
- data/spec/resource_spec.rb +4 -0
- data/spec/user_spec.rb +18 -0
- metadata +5 -2
data/lib/the86-client.rb
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
module The86
|
2
|
+
module Client
|
3
|
+
class AccessToken < Resource
|
4
|
+
|
5
|
+
attribute :id, Integer
|
6
|
+
attribute :token, String
|
7
|
+
attribute :created_at, DateTime
|
8
|
+
attribute :updated_at, DateTime
|
9
|
+
|
10
|
+
belongs_to :user
|
11
|
+
|
12
|
+
path "access_tokens"
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -5,12 +5,21 @@ module The86
|
|
5
5
|
module Client
|
6
6
|
class Connection
|
7
7
|
|
8
|
+
class << self
|
9
|
+
# Parameters for Faraday's connection.adapter method, e.g:
|
10
|
+
# [:rack, SomeApp]
|
11
|
+
attr_writer :faraday_adapter
|
12
|
+
def faraday_adapter
|
13
|
+
@faraday_adapter || Faraday.default_adapter
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
8
17
|
def initialize
|
9
18
|
@faraday = Faraday.new(url) do |conn|
|
10
19
|
conn.request :json
|
11
20
|
conn.response :json
|
12
21
|
conn.basic_auth(*Client.credentials)
|
13
|
-
conn.adapter
|
22
|
+
conn.adapter *self.class.faraday_adapter
|
14
23
|
end
|
15
24
|
end
|
16
25
|
|
data/lib/the86-client/user.rb
CHANGED
data/lib/the86-client/version.rb
CHANGED
data/spec/resource_spec.rb
CHANGED
@@ -27,6 +27,10 @@ module The86::Client
|
|
27
27
|
resource.new(code: "A", parent: parent_resource.new(id: 1)).
|
28
28
|
wont_equal resource.new(code: "A", parent: parent_resource.new(id: 2))
|
29
29
|
end
|
30
|
+
|
31
|
+
it "is inequal to another type of object" do
|
32
|
+
resource.new(id: 1, code: "A").wont_equal false
|
33
|
+
end
|
30
34
|
end
|
31
35
|
end
|
32
36
|
end
|
data/spec/user_spec.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require_relative "spec_helper"
|
2
|
+
|
3
|
+
module The86::Client
|
4
|
+
describe User do
|
5
|
+
|
6
|
+
it "stores name" do
|
7
|
+
User.new(name: "John").name.must_equal "John"
|
8
|
+
end
|
9
|
+
|
10
|
+
it "can store access tokens passed into constructor" do
|
11
|
+
u = User.new(access_tokens: [{token: "one"}, {token: "two"}])
|
12
|
+
u.access_tokens.first.must_be_instance_of AccessToken
|
13
|
+
u.access_tokens.first.token.must_equal "one"
|
14
|
+
u.access_tokens[1].token.must_equal "two"
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: the86-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-07-
|
12
|
+
date: 2012-07-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|
@@ -201,6 +201,7 @@ files:
|
|
201
201
|
- README.md
|
202
202
|
- Rakefile
|
203
203
|
- lib/the86-client.rb
|
204
|
+
- lib/the86-client/access_token.rb
|
204
205
|
- lib/the86-client/active_model.rb
|
205
206
|
- lib/the86-client/connection.rb
|
206
207
|
- lib/the86-client/conversation.rb
|
@@ -219,6 +220,7 @@ files:
|
|
219
220
|
- spec/resource_spec.rb
|
220
221
|
- spec/spec_helper.rb
|
221
222
|
- spec/support/webmock.rb
|
223
|
+
- spec/user_spec.rb
|
222
224
|
- spec/users_spec.rb
|
223
225
|
- the86-client.gemspec
|
224
226
|
homepage: https://github.com/sitepoint/the86-client
|
@@ -253,4 +255,5 @@ test_files:
|
|
253
255
|
- spec/resource_spec.rb
|
254
256
|
- spec/spec_helper.rb
|
255
257
|
- spec/support/webmock.rb
|
258
|
+
- spec/user_spec.rb
|
256
259
|
- spec/users_spec.rb
|