calendly 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/gem-push.yml +37 -0
- data/.github/workflows/test.yml +21 -0
- data/.gitignore +10 -0
- data/.rubocom.yml +69 -0
- data/CHANGELOG.md +50 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +137 -0
- data/Rakefile +10 -0
- data/bin/console +7 -0
- data/bin/setup +6 -0
- data/calendly.gemspec +40 -0
- data/lib/calendly/api_error.rb +42 -0
- data/lib/calendly/client.rb +442 -0
- data/lib/calendly/configuration.rb +26 -0
- data/lib/calendly/error.rb +23 -0
- data/lib/calendly/models/event.rb +99 -0
- data/lib/calendly/models/event_type.rb +88 -0
- data/lib/calendly/models/invitee.rb +77 -0
- data/lib/calendly/models/invitee_question_and_answer.rb +19 -0
- data/lib/calendly/models/invitee_tracking.rb +28 -0
- data/lib/calendly/models/location.rb +53 -0
- data/lib/calendly/models/model_utils.rb +105 -0
- data/lib/calendly/models/organization.rb +63 -0
- data/lib/calendly/models/organization_invitation.rb +67 -0
- data/lib/calendly/models/organization_membership.rb +56 -0
- data/lib/calendly/models/user.rb +100 -0
- data/lib/calendly/version.rb +5 -0
- data/lib/calendly.rb +19 -0
- metadata +189 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3a6dc0f127f4092b13891a3e4515f513973f23fc287ed6ee5b4b2cfd76f46f68
|
4
|
+
data.tar.gz: bc724082ae45976974c064899a63080a2ab1b9fea521fa301706c7e732efd9e3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 885928fabc15c7a08c6a670255b5da769a5e59637d2832e863dd7b54a2146217544a3fdfd2461714ce4e9819adbbcc95deb12eaece81fa45167893b97f0101d1
|
7
|
+
data.tar.gz: 1a010d94d5feaa3c2103dc10608cb20364fadcaddc0cfa51f5b7e39ed062bbd218d6c40e1d86e84f384035230500f7141b30cc9cfd95006abe5160f05f6039d1
|
@@ -0,0 +1,37 @@
|
|
1
|
+
name: Ruby Gem
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [master]
|
6
|
+
|
7
|
+
jobs:
|
8
|
+
build:
|
9
|
+
name: Build + Publish
|
10
|
+
runs-on: ubuntu-latest
|
11
|
+
|
12
|
+
steps:
|
13
|
+
- uses: actions/checkout@v2
|
14
|
+
- name: Set up Ruby 2.6
|
15
|
+
uses: actions/setup-ruby@v1
|
16
|
+
with:
|
17
|
+
ruby-version: 2.6
|
18
|
+
|
19
|
+
- name: Build and test
|
20
|
+
run: |
|
21
|
+
gem install bundler
|
22
|
+
bundle install --jobs 4 --retry 3
|
23
|
+
bundle exec rake test
|
24
|
+
env:
|
25
|
+
CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}}
|
26
|
+
|
27
|
+
- name: Publish to RubyGems
|
28
|
+
run: |
|
29
|
+
mkdir -p $HOME/.gem
|
30
|
+
touch $HOME/.gem/credentials
|
31
|
+
chmod 0600 $HOME/.gem/credentials
|
32
|
+
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
33
|
+
gem build *.gemspec
|
34
|
+
gem push *.gem
|
35
|
+
continue-on-error: true
|
36
|
+
env:
|
37
|
+
GEM_HOST_API_KEY: ${{secrets.RUBYGEMS_AUTH_TOKEN}}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
name: Test
|
2
|
+
|
3
|
+
on: pull_request
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
test:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
|
9
|
+
steps:
|
10
|
+
- uses: actions/checkout@v2
|
11
|
+
- name: Set up Ruby
|
12
|
+
uses: ruby/setup-ruby@v1
|
13
|
+
with:
|
14
|
+
ruby-version: 2.6
|
15
|
+
- name: Build and test
|
16
|
+
run: |
|
17
|
+
gem install bundler
|
18
|
+
bundle install --jobs 4 --retry 3
|
19
|
+
bundle exec rake test
|
20
|
+
env:
|
21
|
+
CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}}
|
data/.gitignore
ADDED
data/.rubocom.yml
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.6
|
3
|
+
|
4
|
+
Layout/AccessModifierIndentation:
|
5
|
+
EnforcedStyle: outdent
|
6
|
+
|
7
|
+
Layout/HashAlignment:
|
8
|
+
Enabled: false
|
9
|
+
|
10
|
+
Layout/DotPosition:
|
11
|
+
EnforcedStyle: trailing
|
12
|
+
|
13
|
+
Layout/SpaceInsideHashLiteralBraces:
|
14
|
+
EnforcedStyle: no_space
|
15
|
+
|
16
|
+
Lint/SuppressedException:
|
17
|
+
Enabled: false
|
18
|
+
|
19
|
+
Metrics/BlockLength:
|
20
|
+
Enabled: false
|
21
|
+
|
22
|
+
Metrics/BlockNesting:
|
23
|
+
Max: 2
|
24
|
+
|
25
|
+
Layout/LineLength:
|
26
|
+
AllowURI: true
|
27
|
+
Enabled: false
|
28
|
+
|
29
|
+
Metrics/MethodLength:
|
30
|
+
CountComments: false
|
31
|
+
Max: 15
|
32
|
+
|
33
|
+
Metrics/ParameterLists:
|
34
|
+
Max: 4
|
35
|
+
CountKeywordArgs: true
|
36
|
+
|
37
|
+
Metrics/AbcSize:
|
38
|
+
Enabled: false
|
39
|
+
|
40
|
+
Style/CollectionMethods:
|
41
|
+
PreferredMethods:
|
42
|
+
map: 'collect'
|
43
|
+
reduce: 'inject'
|
44
|
+
find: 'detect'
|
45
|
+
find_all: 'select'
|
46
|
+
|
47
|
+
Style/Documentation:
|
48
|
+
Enabled: false
|
49
|
+
|
50
|
+
Style/DoubleNegation:
|
51
|
+
Enabled: false
|
52
|
+
|
53
|
+
Style/EachWithObject:
|
54
|
+
Enabled: false
|
55
|
+
|
56
|
+
Style/Encoding:
|
57
|
+
Enabled: false
|
58
|
+
|
59
|
+
Style/ExpandPathArguments:
|
60
|
+
Enabled: false
|
61
|
+
|
62
|
+
Style/HashSyntax:
|
63
|
+
EnforcedStyle: hash_rockets
|
64
|
+
|
65
|
+
Style/Lambda:
|
66
|
+
Enabled: false
|
67
|
+
|
68
|
+
Style/RaiseArgs:
|
69
|
+
EnforcedStyle: compact
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# 0.1.0
|
2
|
+
|
3
|
+
- define methods to access associated resources with each model.
|
4
|
+
- rename methods:
|
5
|
+
- `Calendly::Client#events` to `Calendly::Client#scheduled_events`
|
6
|
+
|
7
|
+
# 0.0.7.alpha
|
8
|
+
|
9
|
+
- support APIs
|
10
|
+
- `POST /organizations/{uuid}/invitations`
|
11
|
+
- `DELETE /organizations/{org_uuid}/invitations/{invitation_uuid}`
|
12
|
+
- `DELETE /organization_memberships/{uuid}`
|
13
|
+
|
14
|
+
# 0.0.6.alpha
|
15
|
+
|
16
|
+
- support APIs
|
17
|
+
- `GET /organizations/{uuid}/invitations`
|
18
|
+
- `GET /organizations/{organization_uuid}/invitations/{invitation_uuid}`
|
19
|
+
|
20
|
+
# 0.0.5.alpha
|
21
|
+
|
22
|
+
- support APIs
|
23
|
+
- `GET /organization_memberships`
|
24
|
+
- `GET /organization_memberships/{uuid}`
|
25
|
+
- rename fields
|
26
|
+
- Invitee#event to Invitee#event_uri
|
27
|
+
- Event#event_type to Event#event_type_uri
|
28
|
+
|
29
|
+
# 0.0.4.alpha
|
30
|
+
|
31
|
+
- support APIs
|
32
|
+
- `GET /scheduled_events/{event_uuid}/invitees`
|
33
|
+
- `GET /scheduled_events/{event_uuid}/invitees/{invitee_uuid}`
|
34
|
+
|
35
|
+
# 0.0.3.alpha
|
36
|
+
|
37
|
+
- support APIs
|
38
|
+
- `GET /scheduled_events`
|
39
|
+
- `GET /scheduled_events/{uuid}`
|
40
|
+
|
41
|
+
# 0.0.2.alpha
|
42
|
+
|
43
|
+
- support APIs
|
44
|
+
- `GET /event_types`
|
45
|
+
|
46
|
+
# 0.0.1.alpha
|
47
|
+
|
48
|
+
- Initial release
|
49
|
+
- support APIs
|
50
|
+
- `GET /users/{uuid}`
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at koshikawa2009@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [https://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: https://contributor-covenant.org
|
74
|
+
[version]: https://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Kenji Koshikawa
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
# Calendly APIs client
|
2
|
+
|
3
|
+
[![Test](https://github.com/koshilife/calendly-api-ruby-client/workflows/Test/badge.svg)](https://github.com/koshilife/calendly-api-ruby-client/actions?query=workflow%3ATest)
|
4
|
+
[![codecov](https://codecov.io/gh/koshilife/calendly-api-ruby-client/branch/master/graph/badge.svg)](https://codecov.io/gh/koshilife/calendly-api-ruby-client)
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/calendly.svg)](http://badge.fury.io/rb/calendly)
|
6
|
+
[![license](https://img.shields.io/github/license/koshilife/calendly-api-ruby-client)](https://github.com/koshilife/calendly-api-ruby-client/blob/master/LICENSE.txt)
|
7
|
+
|
8
|
+
## About
|
9
|
+
|
10
|
+
These client libraries are created for [Calendly v2 APIs](https://calendly.stoplight.io/docs/gh/calendly/api-docs).
|
11
|
+
|
12
|
+
As of August 2020, Calendly v2 API is currently undergoing an upgrade.
|
13
|
+
This library is trying to follow and support for the upgrade.
|
14
|
+
|
15
|
+
As of now the supported statuses each Calendly API are as below.
|
16
|
+
|
17
|
+
## Supported statuses each Calendly API
|
18
|
+
|
19
|
+
- User
|
20
|
+
- [x] Get basic information about a user
|
21
|
+
- EventType
|
22
|
+
- [ ] Get Event Type (This endpoint hasn't been released yet.)
|
23
|
+
- [x] User Event Types
|
24
|
+
- Organization
|
25
|
+
- [x] Get Organization Invitation
|
26
|
+
- [x] Get Organization Invitations
|
27
|
+
- [x] Get Organization Membership
|
28
|
+
- [x] Get a list of Organization Memberships
|
29
|
+
- [x] Invite a person to Organization
|
30
|
+
- [x] Remove a User from an Organization
|
31
|
+
- [x] Revoke Organization Invitation
|
32
|
+
- ScheduledEvent
|
33
|
+
- [x] Get Event
|
34
|
+
- [x] Get Invitee of an Event
|
35
|
+
- [x] Get List of Event Invitees
|
36
|
+
- [x] Get List of User Events
|
37
|
+
- Webhook V2
|
38
|
+
- These endpoints havn't been released yet.
|
39
|
+
|
40
|
+
## Installation
|
41
|
+
|
42
|
+
Add this line to your application's Gemfile:
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
gem 'calendly'
|
46
|
+
```
|
47
|
+
|
48
|
+
And then execute:
|
49
|
+
|
50
|
+
$ bundle
|
51
|
+
|
52
|
+
Or install it yourself as:
|
53
|
+
|
54
|
+
$ gem install calendly
|
55
|
+
|
56
|
+
## Usage
|
57
|
+
|
58
|
+
The APIs client needs access token.
|
59
|
+
This client setup step is below.
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
# set token by Calendly.configure methods.
|
63
|
+
Calendly.configure do |config|
|
64
|
+
config.token = '<ACCESS_TOKEN>'
|
65
|
+
# follows are options. you can refresh access token if these are set.
|
66
|
+
config.client_id = '<CLIENT_ID>'
|
67
|
+
config.client_secret = '<CLIENT_SECRET>'
|
68
|
+
config.refresh_token = '<REFRESH_ACCESS_TOKEN>'
|
69
|
+
config.token_expires_at = '<ACCESS_TOKEN_EXPIRES_AT>'
|
70
|
+
end
|
71
|
+
client = Calendly::Client.new
|
72
|
+
|
73
|
+
|
74
|
+
# set token by Calendly::Client initializer.
|
75
|
+
client = Calendly::Client.new '<ACCESS_TOKEN>'
|
76
|
+
```
|
77
|
+
|
78
|
+
This client basic usage is below.
|
79
|
+
|
80
|
+
```ruby
|
81
|
+
# get a current user's information.
|
82
|
+
me = client.me
|
83
|
+
# => <Calendly::User uuid:U001>
|
84
|
+
me.scheduling_url
|
85
|
+
# => "https://calendly.com/your_name"
|
86
|
+
|
87
|
+
# get all Event Types
|
88
|
+
event_types = me.event_types
|
89
|
+
# => [#<Calendly::EventType uuid:ET001>, #<Calendly::EventType uuid:ET002>, #<Calendly::EventType uuid:ET003>]
|
90
|
+
event_types.first.scheduling_url
|
91
|
+
# => "https://calendly.com/your_name/30min"
|
92
|
+
|
93
|
+
# get scheduled events
|
94
|
+
events = me.scheduled_events
|
95
|
+
# => => [#<Calendly::Event uuid:EV001>, #<Calendly::Event uuid:EV002>, #<Calendly::Event uuid:EV003>]
|
96
|
+
ev = events.first
|
97
|
+
ev.name
|
98
|
+
# => "FooBar Meeting"
|
99
|
+
ev.start_time
|
100
|
+
# => 2020-07-22 01:30:00 UTC
|
101
|
+
ev.end_time
|
102
|
+
# => 2020-07-22 02:00:00 UTC
|
103
|
+
|
104
|
+
# get organization information
|
105
|
+
own_member = me.organization_membership
|
106
|
+
# => #<Calendly::OrganizationMembership uuid:MEM001>
|
107
|
+
my_org = own_member.organization
|
108
|
+
all_members = my_org.memberships
|
109
|
+
# => [#<Calendly::OrganizationMembership uuid:MEM001>, #<Calendly::OrganizationMembership uuid:MEM002>]
|
110
|
+
|
111
|
+
# create new invitation and send invitation email
|
112
|
+
invitation = my_org.create_invitation('foobar@example.com')
|
113
|
+
# => #<Calendly::OrganizationInvitation uuid:INV001>
|
114
|
+
invitation.status
|
115
|
+
# => "pending"
|
116
|
+
|
117
|
+
# cancel the invitation
|
118
|
+
invitation.delete
|
119
|
+
|
120
|
+
# if the log level set :debug, you can get the request/response information.
|
121
|
+
Calendly.configuration.logger.level = :debug
|
122
|
+
invitation = my_org.create_invitation('foobar@example.com')
|
123
|
+
# D, [2020-08-10T10:48:15] DEBUG -- : Request POST https://api.calendly.com/organizations/ORG001/invitations params:, body:{:email=>"foobar@example.com"}
|
124
|
+
# D, [2020-08-10T10:48:16] DEBUG -- : Response status:201, body:{"resource":{"created_at":"2020-08-10T10:48:16.051159Z","email":"foobar@example.com","last_sent_at":"2020-08-10T10:48:16.096518Z","organization":"https://api.calendly.com/organizations/ORG001","status":"pending","updated_at":"2020-08-10T10:48:16.051159Z","uri":"https://api.calendly.com/organizations/ORG001/invitations/INV001"}}
|
125
|
+
```
|
126
|
+
|
127
|
+
## Contributing
|
128
|
+
|
129
|
+
Bug reports and pull requests are welcome on [GitHub](https://github.com/koshilife/calendly-api-ruby-client). This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
130
|
+
|
131
|
+
## License
|
132
|
+
|
133
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
134
|
+
|
135
|
+
## Code of Conduct
|
136
|
+
|
137
|
+
Everyone interacting in the Calendly Api Client project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/koshilife/calendly-api-ruby-client/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
data/bin/setup
ADDED
data/calendly.gemspec
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'lib/calendly/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'calendly'
|
7
|
+
spec.version = Calendly::VERSION
|
8
|
+
spec.authors = ['Kenji Koshikawa']
|
9
|
+
spec.email = ['koshikawa2009@gmail.com']
|
10
|
+
|
11
|
+
spec.description = 'Client for accessing Calendly APIs'
|
12
|
+
spec.summary = spec.description
|
13
|
+
spec.homepage = 'https://github.com/koshilife/calendly-api-ruby-client'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.4.0')
|
16
|
+
|
17
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
18
|
+
spec.metadata['source_code_uri'] = 'https://github.com/koshilife/calendly-api-ruby-client'
|
19
|
+
spec.metadata['changelog_uri'] = "#{spec.metadata['source_code_uri']}/blob/master/CHANGELOG.md"
|
20
|
+
spec.metadata['documentation_uri'] = "https://www.rubydoc.info/gems/calendly/#{spec.version}"
|
21
|
+
|
22
|
+
# Specify which files should be added to the gem when it is released.
|
23
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
24
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
25
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
end
|
27
|
+
spec.bindir = 'exe'
|
28
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
29
|
+
spec.require_paths = ['lib']
|
30
|
+
|
31
|
+
spec.add_runtime_dependency 'oauth2', '>= 1.4.4'
|
32
|
+
spec.add_runtime_dependency 'zeitwerk', '>= 2.3.0'
|
33
|
+
|
34
|
+
spec.add_development_dependency 'bundler'
|
35
|
+
spec.add_development_dependency 'codecov'
|
36
|
+
spec.add_development_dependency 'minitest'
|
37
|
+
spec.add_development_dependency 'rake'
|
38
|
+
spec.add_development_dependency 'simplecov'
|
39
|
+
spec.add_development_dependency 'webmock'
|
40
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Calendly
|
4
|
+
# Calendly apis client error object.
|
5
|
+
class ApiError < Calendly::Error
|
6
|
+
# @return [Faraday::Response]
|
7
|
+
attr_reader :response
|
8
|
+
# @return [Integer]
|
9
|
+
attr_reader :status
|
10
|
+
# @return [String]
|
11
|
+
attr_reader :title
|
12
|
+
# @return [OAuth2::Error, JSON::ParserError]
|
13
|
+
attr_reader :cause_exception
|
14
|
+
|
15
|
+
def initialize(response, cause_exception, message: nil)
|
16
|
+
@response = response
|
17
|
+
@cause_exception = cause_exception
|
18
|
+
@message = message
|
19
|
+
set_attributes_from_response
|
20
|
+
@message ||= cause_exception.message if cause_exception
|
21
|
+
super @message
|
22
|
+
end
|
23
|
+
|
24
|
+
def inspect
|
25
|
+
"\#<#{self.class}:#{object_id} title:#{title}, status:#{status}>"
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def set_attributes_from_response
|
31
|
+
return unless response
|
32
|
+
return unless response.respond_to? :body
|
33
|
+
|
34
|
+
@status = response.status if response.respond_to? :status
|
35
|
+
parsed = JSON.parse response.body, symbolize_names: true
|
36
|
+
@title = parsed[:title] || parsed[:error]
|
37
|
+
@message ||= parsed[:message] || parsed[:error_description]
|
38
|
+
rescue JSON::ParserError
|
39
|
+
nil
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|