calendlyr 0.3.5 → 0.3.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 716fb90f54ab5c73f5441ccb7d8d6f8e636bceb3b3f55a6a9053fc06adabb2b0
4
- data.tar.gz: 6bebccb4df4028bfdbad116fdef8b49768e640f4858dbb1fc7a930d98cf558f0
3
+ metadata.gz: e53e19c9a9bcc92787f9fe776a53e64668eb13939ff7cddb8ebc42220a2346f2
4
+ data.tar.gz: 3a36e15c5c436c852edbf69d177e147b3bf7615a0a5bec93e7a257947df39f5a
5
5
  SHA512:
6
- metadata.gz: 79f76039110d8ff409c573229851e4cc130772f210a769d41bb2dac8ac05679b5a9db07a1d543604dc0e2858cc8c604dac16459fcdbbbeac9e059ce91f0b7267
7
- data.tar.gz: 5de26c0f7b9da6389918ba123935902814ce125dbd193ed50596d06c329044bb161cacb7d9ce5d0b11a032157a01f3e06d6551b2b27d0e542b964f0a5dae11c2
6
+ metadata.gz: c86a6982263871804c661e3f2b554d3d49d253835f4faebac93c6acdcc4538078ba7dd77d837e8e5f8533cf9ae22da05b813c445ea8e90e903e1269a6e138cc5
7
+ data.tar.gz: af2ab8a21873283cdd588267a7c39ba2699e949bb829c15a6a66f61672ad496e69b776ed93849a667cf34e73ab62b1b7eaa7e005165710eca87e9bb5721348b4
@@ -12,7 +12,7 @@ jobs:
12
12
  runs-on: ubuntu-latest
13
13
  strategy:
14
14
  matrix:
15
- ruby: ["2.4", "2.5", "2.6", "2.7", "3.0"]
15
+ ruby: ["2.5", "2.6", "2.7", "3.0"]
16
16
 
17
17
  steps:
18
18
  - uses: actions/checkout@master
data/CHANGELOG.md CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [0.3.6]
6
+ * User caching
7
+
5
8
  ## [0.3.4]
6
9
  * Renaming variables and directories Calendly to Calendlyr
7
10
 
@@ -28,6 +31,7 @@ All notable changes to this project will be documented in this file.
28
31
  ## 0.1.0
29
32
  * Birthday!
30
33
 
34
+ [0.3.6]: https://github.com/araluce/calendlyr/compare/v0.3.4...v0.3.6
31
35
  [0.3.4]: https://github.com/araluce/calendlyr/compare/v0.3.3...v0.3.4
32
36
  [0.3.3]: https://github.com/araluce/calendlyr/compare/v0.3.2...v0.3.3
33
37
  [0.3.2]: https://github.com/araluce/calendlyr/compare/v0.3.0...v0.3.2
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  [![](https://img.shields.io/github/license/araluce/calendlyr)](https://github.com/araluce/calendlyr/blob/master/LICENSE.txt)
2
- ![](https://github.com/araluce/calendlyr/actions/workflows/ci.yml/badge.svg)
2
+ [![](https://github.com/araluce/calendlyr/actions/workflows/ci.yml/badge.svg)](https://github.com/araluce/calendlyr/actions)
3
3
  [![codecov](https://codecov.io/gh/araluce/calendlyr/branch/master/graph/badge.svg?token=YSUU4PHM6Y)](https://codecov.io/gh/araluce/calendlyr)
4
4
  [![Gem Version](https://badge.fury.io/rb/calendlyr.svg)](https://badge.fury.io/rb/calendlyr)
5
5
 
@@ -84,6 +84,17 @@ client.me.memberships
84
84
  #=> Calendlyr::Collection @data=[#<Calendlyr::MemberShip>, #<Calendlyr::MemberShip>]
85
85
  ```
86
86
 
87
+ #### Me (Cached)
88
+
89
+ Probably you need to make many calls through `client.me`, so we decided to not make calls for every `client.me` reference by caching it the first time. However, if you need to reload the content of `me` you can `force_relaod` to force a new call.
90
+
91
+ ```ruby
92
+ client.me # makes a call and caches the response
93
+ client.me # no call, value cached
94
+ client.me(force_reload: true) # makes a new call and update cache value
95
+ ```
96
+
97
+
87
98
  ### Event Types
88
99
  ````ruby
89
100
  client.event_types.list user_uri: "user_uri", organization_uri: "organization_uri"
@@ -118,7 +129,7 @@ client.organization.list_invitations
118
129
  # Get invitation
119
130
  client.organizations.retrieve_invitation(organization_uuid: "organization_uuid", invitation_uuid: "invitation_uuid")
120
131
  client.organization.invitation(invitation_uuid: "invitation_uuid")
121
- #Revoke invitation
132
+ # Revoke invitation
122
133
  client.organizations.revoke_invitation(organization_uuid: "organization_uuid", invitation_uuid: "organization_uuid")
123
134
  client.organization.revoke_invitation(invitation_uuid: "organization_uuid")
124
135
  invitation = client.organization.invitation(invitation_uuid: "invitation_uuid")
@@ -160,4 +171,6 @@ When adding resources, add to the list of resources in lib/calendlyr. Additional
160
171
 
161
172
  ## Thanks
162
173
 
174
+ Many thanks [@markets](https://github.com/markets) for all comments, details and tips for this rubygem project and for made me grow professionally in my day by day :raised_hands:
175
+
163
176
  Thanks [@excid3](https://github.com/excid3) and his [Vultr.rb](https://github.com/excid3/vultr.rb) rubygem project.
@@ -8,8 +8,9 @@ module Calendlyr
8
8
  @token = token
9
9
  end
10
10
 
11
- def me
12
- users.me
11
+ def me(force_reload: false)
12
+ @me = nil if force_reload
13
+ @me ||= users.me
13
14
  end
14
15
 
15
16
  def organization
@@ -1,3 +1,3 @@
1
1
  module Calendlyr
2
- VERSION = "0.3.5"
2
+ VERSION = "0.3.6"
3
3
  end
@@ -28,6 +28,22 @@ class UsersResourceTest < Minitest::Test
28
28
  assert_equal "test@example.com", me.email
29
29
  end
30
30
 
31
+ def test_me_caching
32
+ response = {body: fixture_file("users/retrieve"), status: 200}
33
+ stub = stub(path: "users/me", response: response)
34
+ me = client.me
35
+ remove_request_stub(stub)
36
+ assert_equal client.me, me
37
+ end
38
+
39
+ def test_me_caching_reload
40
+ stub(path: "users/me", response: {body: fixture_file("users/retrieve"), status: 200})
41
+ me = client.me
42
+ stub(path: "users/me", response: {body: fixture_file("users/reload"), status: 200})
43
+ reloaded_me = client.me(force_reload: true)
44
+ assert me.name != reloaded_me.name
45
+ end
46
+
31
47
  def test_organization
32
48
  response = {body: fixture_file("users/retrieve"), status: 200}
33
49
  stub(path: "users/me", response: response)
@@ -0,0 +1,14 @@
1
+ {
2
+ "resource": {
3
+ "uri": "https://api.calendly.com/users/AAAAAAAAAAAAAAAA",
4
+ "name": "John Doe Reloaded",
5
+ "slug": "acmesales",
6
+ "email": "test@example.com",
7
+ "scheduling_url": "https://calendly.com/acmesales",
8
+ "timezone": "America/New York",
9
+ "avatar_url": "https://01234567890.cloudfront.net/uploads/user/avatar/0123456/a1b2c3d4.png",
10
+ "created_at": "2019-01-02T03:04:05.678Z",
11
+ "updated_at": "2019-08-07T06:05:04.321Z",
12
+ "current_organization": "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA"
13
+ }
14
+ }
data/test/test_helper.rb CHANGED
@@ -12,7 +12,7 @@ require "webmock/minitest"
12
12
 
13
13
  class Minitest::Test
14
14
  def client
15
- Calendlyr::Client.new(token: "fake")
15
+ @client ||= Calendlyr::Client.new(token: "fake")
16
16
  end
17
17
 
18
18
  def fixture_file(fixture)
@@ -23,5 +23,6 @@ class Minitest::Test
23
23
  stub_req = stub_request(method, "#{Calendlyr::Client::BASE_URL}/#{path}")
24
24
  stub_req.with(body: body) if [:post, :put, :patch].include?(method)
25
25
  stub_req.to_return(**response)
26
+ stub_req
26
27
  end
27
28
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: calendlyr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - araluce
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-23 00:00:00.000000000 Z
11
+ date: 2021-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -165,6 +165,7 @@ files:
165
165
  - test/fixtures/organizations/retrieve_membership.json
166
166
  - test/fixtures/organizations/revoke_invitation.json
167
167
  - test/fixtures/scheduling_links/create.json
168
+ - test/fixtures/users/reload.json
168
169
  - test/fixtures/users/retrieve.json
169
170
  - test/fixtures/webhooks/create.json
170
171
  - test/fixtures/webhooks/delete.json
@@ -222,6 +223,7 @@ test_files:
222
223
  - test/fixtures/organizations/retrieve_membership.json
223
224
  - test/fixtures/organizations/revoke_invitation.json
224
225
  - test/fixtures/scheduling_links/create.json
226
+ - test/fixtures/users/reload.json
225
227
  - test/fixtures/users/retrieve.json
226
228
  - test/fixtures/webhooks/create.json
227
229
  - test/fixtures/webhooks/delete.json