google-wrapper 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3eddbb3710e316e34a6ceedead992c7c1e8be108
4
- data.tar.gz: 3c1e882cb6859d1f2a701ae4bb3663faa0338c15
3
+ metadata.gz: 6c17a459947e6bf7ce2584117f9f18b668dba8fe
4
+ data.tar.gz: 3608dc57de71f54a78a1c4acae7439a714270f5b
5
5
  SHA512:
6
- metadata.gz: ceed911817da4c84995aa09c1d9ee0ab846a97c4531819278863878a334f2f7d836e556dee937ab78800b89e5a6dc47b486ffb479e34ce932565f825ed707427
7
- data.tar.gz: c4e86f3e6267ca0091676761edb4fa629dac2c1d9019bb2f1699689e528c166336c037d9445750c736cff4d07b310a4d18ed47b572680f237ae1dcc96e613dd0
6
+ metadata.gz: 770325884293d88626868f15d11ee5d10ceca09f5a5da1d41a7a3e57987616ae04a61190e0fcc1158d6dfeef9e8707718597de06ad2562460ce34f3c608f87d7
7
+ data.tar.gz: a94ff762bf6db39215024bf2766372b164a8b61e5cf8ef857ff327337688aa2cac7c1ff4fd6bd02b0fee2a060bd3d5a2081f5bdff1b05cff192c58efc66554dc
@@ -24,6 +24,11 @@ module Google
24
24
  parameters: default_query.merge(schemaKey: key))
25
25
  end
26
26
 
27
+ def get(key)
28
+ client.execute!(api_method: schema_api.get,
29
+ parameters: default_query.merge(schemaKey: key)).data
30
+ end
31
+
27
32
  private
28
33
 
29
34
  def schema_api
@@ -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
@@ -1,5 +1,5 @@
1
1
  module Google
2
2
  module Wrapper
3
- VERSION = "0.0.4"
3
+ VERSION = "0.0.5"
4
4
  end
5
5
  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
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: 2015-12-11 00:00:00.000000000 Z
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: