google-wrapper 0.0.4 → 0.0.5
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 +4 -4
- data/lib/google/directory/schema.rb +5 -0
- data/lib/google/directory/user/badges.rb +18 -0
- data/lib/google/wrapper/version.rb +1 -1
- data/spec/google/directory/schema_spec.rb +9 -0
- data/spec/google/directory/user/badges_spec.rb +15 -0
- data/spec/google/directory/user_spec.rb +2 -2
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c17a459947e6bf7ce2584117f9f18b668dba8fe
|
4
|
+
data.tar.gz: 3608dc57de71f54a78a1c4acae7439a714270f5b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 770325884293d88626868f15d11ee5d10ceca09f5a5da1d41a7a3e57987616ae04a61190e0fcc1158d6dfeef9e8707718597de06ad2562460ce34f3c608f87d7
|
7
|
+
data.tar.gz: a94ff762bf6db39215024bf2766372b164a8b61e5cf8ef857ff327337688aa2cac7c1ff4fd6bd02b0fee2a060bd3d5a2081f5bdff1b05cff192c58efc66554dc
|
@@ -2,6 +2,11 @@ module Google
|
|
2
2
|
module Directory
|
3
3
|
class User < BaseApi
|
4
4
|
class Badges < BaseApi
|
5
|
+
def initialize(client = nil, schema_api = nil)
|
6
|
+
super(client)
|
7
|
+
@schema_api = schema_api
|
8
|
+
end
|
9
|
+
|
5
10
|
# Update a users badges
|
6
11
|
#
|
7
12
|
# @param user_key [String] Can be the user's primary email address, alias email address, or unique user ID.
|
@@ -14,6 +19,19 @@ module Google
|
|
14
19
|
body_object: body,
|
15
20
|
parameters: default_query.merge(userKey: user_key))
|
16
21
|
end
|
22
|
+
|
23
|
+
# Update a users badges
|
24
|
+
#
|
25
|
+
# Returns the list of available badges
|
26
|
+
def available
|
27
|
+
schema_api.get("badges").fields.map(&:field_name)
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def schema_api
|
33
|
+
@schema_api ||= Google::Directory::Schema.new(client)
|
34
|
+
end
|
17
35
|
end
|
18
36
|
end
|
19
37
|
end
|
@@ -42,6 +42,15 @@ module Google::Directory
|
|
42
42
|
])
|
43
43
|
expect(parameters).to eql({ customer: "my_customer", customerId: "1234" })
|
44
44
|
end
|
45
|
+
|
46
|
+
it "proxies get to a google api client" do
|
47
|
+
result = schema_api.get("badges")
|
48
|
+
api_method = result.api_method
|
49
|
+
parameters = result.parameters
|
50
|
+
|
51
|
+
expect(api_method.name).to eql("admin.schemas.get")
|
52
|
+
expect(parameters).to eql({ customer: "my_customer", customerId: "1234", schemaKey: "badges" })
|
53
|
+
end
|
45
54
|
end
|
46
55
|
|
47
56
|
describe Schema::Field do
|
@@ -33,5 +33,20 @@ module Google::Directory
|
|
33
33
|
userKey: "john.bohn@alphasights.com"
|
34
34
|
})
|
35
35
|
end
|
36
|
+
|
37
|
+
it "returns the name of available badges from google schema api" do
|
38
|
+
schema_api = double(Google::Directory::Schema)
|
39
|
+
badgeFields = [
|
40
|
+
double(field_name: "foo"),
|
41
|
+
double(field_name: "bar"),
|
42
|
+
]
|
43
|
+
|
44
|
+
schema_double = double({fields: badgeFields})
|
45
|
+
expect(schema_api).to receive(:get).with("badges").and_return(schema_double)
|
46
|
+
|
47
|
+
badges_api = described_class.new(client_spy, schema_api)
|
48
|
+
|
49
|
+
expect(badges_api.available).to eql(%w(foo bar))
|
50
|
+
end
|
36
51
|
end
|
37
52
|
end
|
@@ -12,8 +12,8 @@ module Google::Directory
|
|
12
12
|
it "proxies a get with full project to a google api client when no extra arguments are sent" do
|
13
13
|
result = user_api.get("john.bohn@alphasights.com")
|
14
14
|
|
15
|
-
api_method = result.api_method
|
16
|
-
parameters = result.parameters
|
15
|
+
api_method = result.data.api_method
|
16
|
+
parameters = result.data.parameters
|
17
17
|
|
18
18
|
expect(api_method.name).to eql("admin.users.get")
|
19
19
|
expect(parameters).to eql({
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google-wrapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Bohn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: google-api-client
|
@@ -135,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
135
|
version: '0'
|
136
136
|
requirements: []
|
137
137
|
rubyforge_project:
|
138
|
-
rubygems_version: 2.4.5
|
138
|
+
rubygems_version: 2.4.5.1
|
139
139
|
signing_key:
|
140
140
|
specification_version: 4
|
141
141
|
summary: Small gem to wrap google-api-client
|
@@ -147,3 +147,4 @@ test_files:
|
|
147
147
|
- spec/google/directory/user_spec.rb
|
148
148
|
- spec/google/dummy_client_spec.rb
|
149
149
|
- spec/spec_helper.rb
|
150
|
+
has_rdoc:
|