spearly-sdk-ruby 0.4.0 → 0.5.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
  SHA256:
3
- metadata.gz: c6ca2e7efcf2a6ef0c4c933c9edd49115fc2c82c5d601c34a84c76ca87bd1602
4
- data.tar.gz: 2e924b9bf892c8504034bf654acdda7f28d6bdc36cc01b1bc915f6333b4c5648
3
+ metadata.gz: 13ec9bdf4ea5bf140a8db9a87058c52651fe0631a78f43b1acf116b712270865
4
+ data.tar.gz: e496438935bfdd23172c8acf06f3c70f2407b362231d15bcd4da6908f7c87d03
5
5
  SHA512:
6
- metadata.gz: c73bf97ee424325e8032d2719e25dc38cdfd369fac1f3775af89324f152c513c1a147a3082fefe83dab2b39d03e7f303a75c4a38a54a4e7fbdc5d1fd1c564fb9
7
- data.tar.gz: aa26cc8cb81db6f9587439fc297915deaf88c5bc61e83266390f25a9e6f37da2571de3eb17f040c12dfb8ad10d5800f8d7385ee4fb48fa813d9dc2b9527fb9fd
6
+ metadata.gz: d7cbe36feb66608124b4fb66afc5a7da7564a32af2464cd9bf5ebb3872aca7fe60c23c163bda107479361e4717d3596fee88c506b1160a5e4f0d584421ef0639
7
+ data.tar.gz: b3a9470ca734f081e49f54f2949a03bfaa52fb4c2a4f35039a2d90f50563e44c17351ec3657146efe47dc3de61ec990fe776df8da0308f21c93d41274955bdfe
data/.gitignore CHANGED
@@ -1,11 +1,12 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
-
10
- # rspec failure tracking
1
+ .bundle
11
2
  .rspec_status
3
+ .ruby-version
4
+ .yardoc
5
+ _yardoc/
6
+ coverage/
7
+ doc/
8
+ Gemfile.local
9
+ Gemfile.lock
10
+ pkg/
11
+ spec/reports/
12
+ tmp/
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [0.5.0] - 2021-12-13
2
+
3
+ - Spearly::Auth::Client
4
+
1
5
  ## [0.4.0] - 2021-09-13
2
6
 
3
7
  - Error handling improvements
@@ -0,0 +1,128 @@
1
+ module Spearly
2
+ module Auth
3
+ class Client
4
+ def initialize(token)
5
+ @token = token
6
+ end
7
+
8
+ def create_team(params)
9
+ uri = "#{ENV['SPEARLY_API_URL']}/teams"
10
+ uri_parsed = Addressable::URI.parse(uri).normalize.to_s
11
+ client = Faraday.default_connection
12
+
13
+ res = client.post(uri_parsed,
14
+ params.as_json,
15
+ 'Accept' => 'application/vnd.spearly.v2+json',
16
+ 'Authorization' => @token)
17
+
18
+ if res.status == 201
19
+ JSON.parse(res.body)['data']
20
+ else
21
+ {}
22
+ end
23
+ end
24
+
25
+ def get_team(team_id)
26
+ uri = "#{ENV['SPEARLY_API_URL']}/teams/#{team_id}"
27
+ uri_parsed = Addressable::URI.parse(uri).normalize.to_s
28
+ client = Faraday.default_connection
29
+
30
+ res = client.get(uri_parsed,
31
+ nil,
32
+ 'Accept' => 'application/vnd.spearly.v2+json',
33
+ 'Authorization' => @token)
34
+
35
+ if res.status == 200
36
+ JSON.parse(res.body)['data']
37
+ else
38
+ {}
39
+ end
40
+ end
41
+
42
+ def get_teams(params = {})
43
+ uri = "#{ENV['SPEARLY_API_URL']}/teams"
44
+ uri_parsed = Addressable::URI.parse(uri).normalize.to_s
45
+ client = Faraday.default_connection
46
+
47
+ res = client.get(uri_parsed,
48
+ params.as_json,
49
+ 'Accept' => 'application/vnd.spearly.v2+json',
50
+ 'Authorization' => @token)
51
+
52
+ if res.status == 200
53
+ JSON.parse(res.body)['data']
54
+ else
55
+ []
56
+ end
57
+ end
58
+
59
+ def update_team(team_id, params)
60
+ uri = "#{ENV['SPEARLY_API_URL']}/teams/#{team_id}"
61
+ uri_parsed = Addressable::URI.parse(uri).normalize.to_s
62
+ client = Faraday.default_connection
63
+
64
+ res = client.put(uri_parsed,
65
+ params.as_json,
66
+ 'Accept' => 'application/vnd.spearly.v2+json',
67
+ 'Authorization' => @token)
68
+
69
+ if res.status == 200
70
+ JSON.parse(res.body)['data']
71
+ else
72
+ nil
73
+ end
74
+ end
75
+
76
+ def regenerate_team_api_access_token(team_id)
77
+ uri = "#{ENV['SPEARLY_API_URL']}/teams/#{team_id}/regenerate_api_access_token"
78
+ uri_parsed = Addressable::URI.parse(uri).normalize.to_s
79
+ client = Faraday.default_connection
80
+
81
+ res = client.post(uri_parsed,
82
+ nil,
83
+ 'Accept' => 'application/vnd.spearly.v2+json',
84
+ 'Authorization' => @token)
85
+
86
+ if res.status == 200
87
+ JSON.parse(res.body)['data']
88
+ else
89
+ nil
90
+ end
91
+ end
92
+
93
+ def invite_user_to_team(team_id, params)
94
+ uri = "#{ENV['SPEARLY_API_URL']}/teams/#{team_id}/invite"
95
+ uri_parsed = Addressable::URI.parse(uri).normalize.to_s
96
+ client = Faraday.default_connection
97
+
98
+ res = client.post(uri_parsed,
99
+ params.as_json,
100
+ 'Accept' => 'application/vnd.spearly.v2+json',
101
+ 'Authorization' => @token)
102
+
103
+ if res.status == 201
104
+ JSON.parse(res.body)['data']
105
+ else
106
+ nil
107
+ end
108
+ end
109
+
110
+ def get_team_members(team_id)
111
+ uri = "#{ENV['SPEARLY_API_URL']}/teams/#{team_id}/members"
112
+ uri_parsed = Addressable::URI.parse(uri).normalize.to_s
113
+ client = Faraday.default_connection
114
+
115
+ res = client.get(uri_parsed,
116
+ nil,
117
+ 'Accept' => 'application/vnd.spearly.v2+json',
118
+ 'Authorization' => @token)
119
+
120
+ if res.status == 200
121
+ JSON.parse(res.body)['data']
122
+ else
123
+ []
124
+ end
125
+ end
126
+ end
127
+ end
128
+ end
@@ -1,8 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'addressable/uri'
4
- require 'faraday'
5
-
6
3
  module Spearly
7
4
  module Auth
8
5
  class Team
data/lib/spearly/auth.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'auth/authorizer'
4
+ require_relative 'auth/client'
4
5
  require_relative 'auth/engine'
5
6
  require_relative 'auth/oauth_user'
6
7
  require_relative 'auth/team'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Spearly
4
- VERSION = '0.4.0'
4
+ VERSION = '0.5.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spearly-sdk-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Spearly
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-13 00:00:00.000000000 Z
11
+ date: 2021-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -142,7 +142,6 @@ files:
142
142
  - ".rubocop.yml"
143
143
  - CHANGELOG.md
144
144
  - Gemfile
145
- - Gemfile.lock
146
145
  - README.md
147
146
  - Rakefile
148
147
  - bin/console
@@ -151,6 +150,7 @@ files:
151
150
  - lib/spearly.rb
152
151
  - lib/spearly/auth.rb
153
152
  - lib/spearly/auth/authorizer.rb
153
+ - lib/spearly/auth/client.rb
154
154
  - lib/spearly/auth/engine.rb
155
155
  - lib/spearly/auth/oauth_user.rb
156
156
  - lib/spearly/auth/rails/helpers.rb
@@ -166,7 +166,7 @@ licenses: []
166
166
  metadata:
167
167
  homepage_uri: https://github.com/unimal-jp/spearly-sdk-ruby
168
168
  source_code_uri: https://github.com/unimal-jp/spearly-sdk-ruby
169
- changelog_uri: https://github.com/unimal-jp/spearly-sdk-ruby/blob/v0.4.0/CHANGELOG.md
169
+ changelog_uri: https://github.com/unimal-jp/spearly-sdk-ruby/blob/v0.5.0/CHANGELOG.md
170
170
  post_install_message:
171
171
  rdoc_options: []
172
172
  require_paths:
data/Gemfile.lock DELETED
@@ -1,100 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- spearly-sdk-ruby (0.3.1)
5
- addressable (~> 2.3)
6
- faraday (>= 0.17.4, < 2.0)
7
- rake (~> 13.0)
8
- signet (~> 0.15)
9
-
10
- GEM
11
- remote: https://rubygems.org/
12
- specs:
13
- addressable (2.8.0)
14
- public_suffix (>= 2.0.2, < 5.0)
15
- ast (2.4.2)
16
- coderay (1.1.3)
17
- diff-lcs (1.4.4)
18
- faraday (1.7.1)
19
- faraday-em_http (~> 1.0)
20
- faraday-em_synchrony (~> 1.0)
21
- faraday-excon (~> 1.1)
22
- faraday-httpclient (~> 1.0.1)
23
- faraday-net_http (~> 1.0)
24
- faraday-net_http_persistent (~> 1.1)
25
- faraday-patron (~> 1.0)
26
- faraday-rack (~> 1.0)
27
- multipart-post (>= 1.2, < 3)
28
- ruby2_keywords (>= 0.0.4)
29
- faraday-em_http (1.0.0)
30
- faraday-em_synchrony (1.0.0)
31
- faraday-excon (1.1.0)
32
- faraday-httpclient (1.0.1)
33
- faraday-net_http (1.0.1)
34
- faraday-net_http_persistent (1.2.0)
35
- faraday-patron (1.0.0)
36
- faraday-rack (1.0.0)
37
- jwt (2.2.3)
38
- method_source (1.0.0)
39
- multi_json (1.15.0)
40
- multipart-post (2.1.1)
41
- parallel (1.20.1)
42
- parser (3.0.1.1)
43
- ast (~> 2.4.1)
44
- pry (0.13.1)
45
- coderay (~> 1.1)
46
- method_source (~> 1.0)
47
- public_suffix (4.0.6)
48
- rainbow (3.0.0)
49
- rake (13.0.6)
50
- regexp_parser (2.1.1)
51
- rexml (3.2.5)
52
- rspec (3.10.0)
53
- rspec-core (~> 3.10.0)
54
- rspec-expectations (~> 3.10.0)
55
- rspec-mocks (~> 3.10.0)
56
- rspec-core (3.10.1)
57
- rspec-support (~> 3.10.0)
58
- rspec-expectations (3.10.1)
59
- diff-lcs (>= 1.2.0, < 2.0)
60
- rspec-support (~> 3.10.0)
61
- rspec-mocks (3.10.2)
62
- diff-lcs (>= 1.2.0, < 2.0)
63
- rspec-support (~> 3.10.0)
64
- rspec-support (3.10.2)
65
- rubocop (1.15.0)
66
- parallel (~> 1.10)
67
- parser (>= 3.0.0.0)
68
- rainbow (>= 2.2.2, < 4.0)
69
- regexp_parser (>= 1.8, < 3.0)
70
- rexml
71
- rubocop-ast (>= 1.5.0, < 2.0)
72
- ruby-progressbar (~> 1.7)
73
- unicode-display_width (>= 1.4.0, < 3.0)
74
- rubocop-ast (1.5.0)
75
- parser (>= 3.0.1.1)
76
- rubocop-rspec (2.3.0)
77
- rubocop (~> 1.0)
78
- rubocop-ast (>= 1.1.0)
79
- ruby-progressbar (1.11.0)
80
- ruby2_keywords (0.0.5)
81
- signet (0.16.0)
82
- addressable (~> 2.8)
83
- faraday (>= 0.17.3, < 2.0)
84
- jwt (>= 1.5, < 3.0)
85
- multi_json (~> 1.10)
86
- unicode-display_width (2.0.0)
87
-
88
- PLATFORMS
89
- x86_64-darwin-20
90
- x86_64-linux
91
-
92
- DEPENDENCIES
93
- pry (~> 0.13.1)
94
- rspec (~> 3.0)
95
- rubocop (~> 1.15)
96
- rubocop-rspec (~> 2.3)
97
- spearly-sdk-ruby!
98
-
99
- BUNDLED WITH
100
- 2.2.15