ringcentral-avatars 0.0.1 → 0.1.0

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: e54f32761102a609bd4076cf6ffbe88261ac5ee0
4
- data.tar.gz: ccdf57695c53e2662927b203ae10705369574c6c
3
+ metadata.gz: d0de1fd59ec9b1ea838bf6e84407c95945ad7c3a
4
+ data.tar.gz: b1bc23a2801a87ef5a69b8e88c1afe8b7ac26a9e
5
5
  SHA512:
6
- metadata.gz: 55588a39b9a842c70aaa38611d6f7dc2e0fc61dbe62af89425815e644db2c9b9fed4189b4b4b0ff3a5c3915344707c9e0805907e31f98e58fe67181d0f774dcd
7
- data.tar.gz: f59211bf0735da463841934547afc1deb3ca4f0760729e893ba166567654936ebec566fa3d1dc4b3e94a1f5433d6e73a10d0dbbcd69ee85f519f7f9b536e22b4
6
+ metadata.gz: 7ab6a4431c749a1ddd8b209c5c79dda7b77742b15ae9add3fbe3db4d2eebe68bcdc21e4c8c74bdf2ab055a06f8413bdbd2574546ed91c143fcb30f5a6874109c
7
+ data.tar.gz: aafb64c078b6484f52bcb3f7ca7fb0872139406814338136fc10cb2349a31771229a19c0e042db7b2d05d4b3535bd44254212255275e9aec43bd42f855bd0b14
data/CHANGELOG.md CHANGED
@@ -1,6 +1,9 @@
1
1
  CHANGELOG
2
2
  ---------
3
- - **2016-10-22**: 0.0.2
3
+ - **2016-10-22**: 0.1.0
4
+ - Update module name
5
+ - Update method signatures for options
6
+ - **2016-10-22**: 0.0.1
4
7
  - Initial release
5
8
  - Add ability to create Gmail-like avatars
6
9
  - Add ability to create defaults-only and optionally overwrite all
data/README.md CHANGED
@@ -7,13 +7,33 @@ RingCentral Avatars
7
7
  [![Code Climate][codeclimate-status-svg]][codeclimate-status-link]
8
8
  [![Scrutinizer Code Quality][scrutinizer-status-svg]][scrutinizer-status-link]
9
9
  [![Downloads][downloads-svg]][downloads-link]
10
- [![Docs][docs-readthedocs-svg]][docs-readthedocs-link]
11
10
  [![Docs][docs-rubydoc-svg]][docs-rubydoc-link]
12
11
  [![License][license-svg]][license-link]
13
12
 
14
13
  ## Overview
15
14
 
16
- This library will build RingCentral avatars using Gmail-like initial avatars. It requires ImageMagick.
15
+ This library will build RingCentral avatars using Gmail-like initial avatars. It can build Gmail-like avatars for the following:
16
+
17
+ * all RingCentral users (extensions) without images
18
+ * all RingCentral users, overwriting existing images (useful for testing in Sandbox accounts)
19
+ * specific extensions
20
+ * authorized user extension only
21
+
22
+ The images will look like the following in the RingCentral softphone:
23
+
24
+ ![](docs/images/ringcentral-avatars-softphone.png)
25
+
26
+ ## Pre-requisites
27
+
28
+ * This library requires ImageMagick
29
+ * This library requires a RingCentral account
30
+ * A RingCentral administrator account is necessary to update profile images for others
31
+
32
+ ## Installation
33
+
34
+ ```bash
35
+ $ gem install ringcentral-avatars
36
+ ```
17
37
 
18
38
  ## Usage
19
39
 
@@ -23,12 +43,13 @@ require 'ringcentral_sdk'
23
43
 
24
44
  client = RingCentralSdk.new [...]
25
45
 
26
- avatars = RingCentralAvatars.new client
46
+ avatars = RingCentral::Avatars.new client
27
47
 
28
- avatars.create_all # create defaults only
29
- avatars.create_all true # overwrite existing avatars
48
+ avatars.create_defaults # create default avatars only
49
+ avatars.create_all # create all avatars, overwriting existing avatars
30
50
 
31
- avatars.create_mine # create for authorized user only
51
+ avatars.create_mine # does not overwrite user avatar
52
+ avatars.create_mine overwrite: true # overwrite existing user avatars
32
53
  ```
33
54
 
34
55
  ### Change Log
@@ -47,7 +68,7 @@ RingCentral Ruby SDK
47
68
 
48
69
  RingCentral API Explorer
49
70
 
50
- * http://ringcentral.github.io/api-explorer
71
+ * https://developer.ringcentral.com/api-explorer/latest/index.html
51
72
 
52
73
  ## Contributing
53
74
 
@@ -77,8 +98,6 @@ RingCentral Avatars © 2016 by John Wang
77
98
  [codeclimate-status-link]: https://codeclimate.com/github/ringcentral-ruby/ringcentral-avatars-ruby
78
99
  [scrutinizer-status-svg]: https://scrutinizer-ci.com/g/ringcentral-ruby/ringcentral-avatars-ruby/badges/quality-score.png?b=master
79
100
  [scrutinizer-status-link]: https://scrutinizer-ci.com/g/ringcentral-ruby/ringcentral-avatars-ruby/?branch=master
80
- [docs-readthedocs-svg]: https://img.shields.io/badge/docs-readthedocs-blue.svg
81
- [docs-readthedocs-link]: http://ringcentral-avatars-ruby.readthedocs.org/
82
101
  [docs-rubydoc-svg]: https://img.shields.io/badge/docs-rubydoc-blue.svg
83
102
  [docs-rubydoc-link]: http://www.rubydoc.info/gems/ringcentral-avatars/
84
103
  [license-svg]: https://img.shields.io/badge/license-MIT-blue.svg
@@ -1,11 +1,13 @@
1
1
  require 'ringcentral-avatars/creator'
2
2
 
3
- module RingCentralAvatars
4
- VERSION = '0.0.1'
3
+ module RingCentral
4
+ module Avatars
5
+ VERSION = '0.1.0'
5
6
 
6
- class << self
7
- def new(client)
8
- RingCentralAvatars::Creator.new client
7
+ class << self
8
+ def new(client)
9
+ RingCentral::Avatars::Creator.new client
10
+ end
9
11
  end
10
12
  end
11
- end
13
+ end
@@ -3,76 +3,103 @@ require 'faraday'
3
3
  require 'ringcentral_sdk'
4
4
  require 'tempfile'
5
5
 
6
- module RingCentralAvatars
7
- class Creator
8
- DEFAULT_SIZE = 600
6
+ module RingCentral
7
+ module Avatars
8
+ class Creator
9
+ DEFAULT_SIZE = 600
9
10
 
10
- attr_accessor :client
11
- attr_accessor :extensions
11
+ attr_accessor :client
12
+ attr_accessor :extensions
12
13
 
13
- def initialize(client)
14
- @client = client
15
- load_extensions
16
- end
14
+ def initialize(client)
15
+ @client = client
16
+ load_extensions
17
+ end
17
18
 
18
- def create_all(overwrite = false)
19
- @extensions.extensions_hash.each do |ext_id, ext|
20
- create_avatar ext, overwrite
19
+ ##
20
+ # Convenience method for creating default avatars for all extensions
21
+ # Defaults to not overwriting existing avatars
22
+ def create_defaults(opts = {})
23
+ opts[:overwrite] = false
24
+ create_all opts
21
25
  end
22
- load_extensions
23
- end
24
26
 
25
- def create_mine(overwrite = false)
26
- res = @client.http.get 'account/~/extension/~'
27
- create_avatar res.body, overwrite
28
- load_extensions
29
- end
27
+ ##
28
+ # Convenience method for creating avatars for all extensions
29
+ # Defaults to overwriting existing avatar
30
+ def create_all(opts = {})
31
+ opts[:overwrite] = true unless opts.key?(:overwrite)
32
+ @extensions.extensions_hash.each do |ext_id, ext|
33
+ create_avatar ext, opts
34
+ end
35
+ load_extensions
36
+ end
30
37
 
31
- def create_avatar(ext, overwrite = false)
32
- return if has_avatar(ext) && !overwrite
33
- avatar_temp = get_avatar_tmp_file ext
34
- url = "account/~/extension/#{ext['id']}/profile-image"
35
- image = Faraday::UploadIO.new(avatar_temp.path, 'image/png')
36
- @client.http.put url, image: image
37
- end
38
+ ##
39
+ # Convenience method for creating avatar for authorized extension
40
+ # Defaults to not overwriting existing avatar
41
+ def create_mine(opts = {})
42
+ res = @client.http.get 'account/~/extension/~'
43
+ create_avatar res.body, opts
44
+ load_extensions
45
+ end
38
46
 
39
- def has_avatar(ext)
40
- return ext['profileImage'].key?('etag') ? true : false
41
- end
47
+ ##
48
+ # Create the avatar for the extension.
49
+ # Defaults to not overwriting existing avatar
50
+ def create_avatar(ext, opts = {})
51
+ opts[:overwrite] = false unless opts.key?(:overwrite)
52
+ return if has_avatar(ext) && !opts[:overwrite]
53
+ avatar_temp = get_avatar_tmp_file ext
54
+ url = "account/~/extension/#{ext['id']}/profile-image"
55
+ image = Faraday::UploadIO.new(avatar_temp.path, 'image/png')
56
+ @client.http.put url, image: image
57
+ end
42
58
 
43
- def get_avatar_tmp_file(ext)
44
- avatar_blob = Avatarly.generate_avatar(ext['name'], size: DEFAULT_SIZE)
45
- avatar_temp = Tempfile.new(['avatar', '.png'])
46
- avatar_temp.binmode
47
- avatar_temp.write(avatar_blob)
48
- avatar_temp.flush
49
- avatar_temp
50
- end
59
+ ##
60
+ # Determines if extension has an existing avatar
61
+ # Checks by looking ofr the presence of the `etag` property
62
+ def has_avatar(ext)
63
+ return ext['profileImage'].key?('etag') ? true : false
64
+ end
51
65
 
52
- def load_extensions
53
- @extensions = RingCentralSdk::REST::Cache::Extensions.new client
54
- @extensions.retrieve_all
55
- end
66
+ def get_avatar_tmp_file(ext)
67
+ avatar_blob = Avatarly.generate_avatar(ext['name'], size: DEFAULT_SIZE)
68
+ avatar_temp = Tempfile.new(['avatar', '.png'])
69
+ avatar_temp.binmode
70
+ avatar_temp.write(avatar_blob)
71
+ avatar_temp.flush
72
+ avatar_temp
73
+ end
56
74
 
57
- def avatar_urls(include_token = false)
58
- urls = []
59
- @extensions.extensions_hash.keys.sort.each do |ext_id|
60
- ext = @extensions.extensions_hash[ext_id]
61
- urls.push avatar_url(ext, include_token)
75
+ def load_extensions
76
+ @extensions = RingCentralSdk::REST::Cache::Extensions.new client
77
+ @extensions.retrieve_all
62
78
  end
63
- return urls
64
- end
65
79
 
66
- def my_avatar_url(include_token = false)
67
- res = @client.http.get 'account/~/extension/~'
68
- avatar_url(res.body, include_token)
69
- end
80
+ ##
81
+ # Returns a list of avatar URLs which can be useful for testing purposes
82
+ # Adding the current access token is optional
83
+ def avatar_urls(include_token = false)
84
+ urls = []
85
+ @extensions.extensions_hash.keys.sort.each do |ext_id|
86
+ ext = @extensions.extensions_hash[ext_id]
87
+ urls.push avatar_url(ext, include_token)
88
+ end
89
+ return urls
90
+ end
91
+
92
+ def my_avatar_url(include_token = false)
93
+ res = @client.http.get 'account/~/extension/~'
94
+ avatar_url(res.body, include_token)
95
+ end
70
96
 
71
- def avatar_url(ext, include_token = false)
72
- token = @client.token.to_hash[:access_token]
73
- url = ext['profileImage']['uri']
74
- url += "?access_token=#{token}" if include_token
75
- return url
97
+ def avatar_url(ext, include_token = false)
98
+ token = @client.token.to_hash[:access_token]
99
+ url = ext['profileImage']['uri']
100
+ url += "?access_token=#{token}" if include_token
101
+ return url
102
+ end
76
103
  end
77
104
  end
78
105
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ringcentral-avatars
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Wang