springcm-sdk 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +4 -0
- data/.travis.yml +8 -0
- data/CHANGELOG.md +22 -0
- data/README.md +1 -1
- data/lib/springcm.rb +6 -0
- data/lib/springcm/client.rb +29 -5
- data/lib/springcm/version.rb +1 -1
- data/springcm-sdk.gemspec +8 -5
- metadata +39 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 62ce246eed8c9903f1a23c83296df864a39b29e7bdfc0dd1351833854ff9b2d4
|
4
|
+
data.tar.gz: 51bef14dbffb1245439232d41c10eb64d5ce29b31a3e1483aa6973e0be53b4ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f09b65c50f48af5ffa74584137bd79b3cb62fcab93f2b11ddca2089ef1815c82a455e23c6fc3591630a5238d29a37f452856d06e5e95bc25d0acd69f01c85d9d
|
7
|
+
data.tar.gz: d8f334881ad6de05354f696c8738344222750f177b2013e37492e71e1a392f1ce5173d8acd287ebddd768ade0c5d6ee9fe09532c3d911aa1d62469d04d931cd1
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -5,3 +5,11 @@ cache: bundler
|
|
5
5
|
rvm:
|
6
6
|
- 2.5.5
|
7
7
|
before_install: gem install bundler -v 2.0.1
|
8
|
+
before_script:
|
9
|
+
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
10
|
+
- chmod +x ./cc-test-reporter
|
11
|
+
- ./cc-test-reporter before-build
|
12
|
+
script:
|
13
|
+
- bundle exec rspec
|
14
|
+
after_script:
|
15
|
+
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# springcm-sdk changelog
|
2
|
+
|
3
|
+
All notable changes to springcm-sdk will be documented in this file.
|
4
|
+
|
5
|
+
## [Unreleased]
|
6
|
+
|
7
|
+
## [0.1.1] - 2019-07-17
|
8
|
+
### Added
|
9
|
+
* `Client#connect!` method
|
10
|
+
* Documentation generation
|
11
|
+
* Test coverage
|
12
|
+
|
13
|
+
### Changed
|
14
|
+
* Fix issues with gemspec file
|
15
|
+
|
16
|
+
## [0.1.0] - 2019-07-16
|
17
|
+
### Added
|
18
|
+
* Initial release to reserve gem name
|
19
|
+
|
20
|
+
[Unreleased]: https://github.com/paulholden2/springcm-sdk/compare/v0.1.0...HEAD
|
21
|
+
[0.1.0]: https://github.com/paulholden2/springcm-sdk/releases/tag/v0.1.0
|
22
|
+
[0.1.1]: https://github.com/paulholden2/springcm-sdk/releases/tag/v0.1.1
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# SpringCM
|
2
2
|
|
3
|
-
[![Build Status](https://travis-ci.org/paulholden2/springcm-sdk.svg?branch=master)](https://travis-ci.org/paulholden2/springcm-sdk)
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/springcm-sdk.svg)](https://badge.fury.io/rb/springcm-sdk) [![Build Status](https://travis-ci.org/paulholden2/springcm-sdk.svg?branch=master)](https://travis-ci.org/paulholden2/springcm-sdk) [![Maintainability](https://api.codeclimate.com/v1/badges/06e1dd90fde417de15da/maintainability)](https://codeclimate.com/github/paulholden2/springcm-sdk/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/06e1dd90fde417de15da/test_coverage)](https://codeclimate.com/github/paulholden2/springcm-sdk/test_coverage)
|
4
4
|
|
5
5
|
This gem is a library for working with the SpringCM REST API.
|
6
6
|
|
data/lib/springcm.rb
CHANGED
data/lib/springcm/client.rb
CHANGED
@@ -2,6 +2,9 @@ require "faraday"
|
|
2
2
|
|
3
3
|
module Springcm
|
4
4
|
class Client
|
5
|
+
# @param data_center [String] Data center name, e.g. uatna11
|
6
|
+
# @param client_id [String] Your API client ID
|
7
|
+
# @param client_secret [String] Your API client secret
|
5
8
|
def initialize(data_center:, client_id:, client_secret:)
|
6
9
|
if !["na11", "uatna11"].include?(data_center)
|
7
10
|
raise Springcm::ConnectionInfoError.new("Invalid data center '#{data_center.to_s}'")
|
@@ -15,7 +18,10 @@ module Springcm
|
|
15
18
|
@access_token
|
16
19
|
end
|
17
20
|
|
18
|
-
|
21
|
+
# Connect to the configured SpringCM API service
|
22
|
+
# @param safe If truthy, connection failure does not raise an exception
|
23
|
+
# @return [Boolean] Whether connection was successful
|
24
|
+
def connect(safe=true)
|
19
25
|
conn = Faraday.new(url: auth_url)
|
20
26
|
res = conn.post do |req|
|
21
27
|
req.url "/"
|
@@ -24,28 +30,46 @@ module Springcm
|
|
24
30
|
client_secret: @client_secret
|
25
31
|
}.to_json
|
26
32
|
end
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
33
|
+
if res.success?
|
34
|
+
data = JSON.parse(res.body)
|
35
|
+
@access_token = data.fetch("access_token")
|
36
|
+
@expiry = Time.now + data.fetch("expires_in")
|
37
|
+
true
|
38
|
+
else
|
39
|
+
@access_token = nil
|
40
|
+
@expiry = nil
|
41
|
+
raise Springcm::InvalidClientIdOrSecretError.new if !safe
|
42
|
+
false
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# Shorthand for connecting unsafely
|
47
|
+
def connect!
|
48
|
+
connect(false)
|
31
49
|
end
|
32
50
|
|
51
|
+
# Check if client is successfully authenticated
|
52
|
+
# @return [Boolean] Whether a valid, unexpired access token is held.
|
33
53
|
def authenticated?
|
34
54
|
!!@access_token && @expiry > Time.now
|
35
55
|
end
|
36
56
|
|
57
|
+
# Get the URL for object API requests
|
37
58
|
def object_api_url
|
38
59
|
"https://api#{@data_center}.springcm.com/v#{@api_version}"
|
39
60
|
end
|
40
61
|
|
62
|
+
# Get the URL for content upload API requests
|
41
63
|
def upload_api_url
|
42
64
|
"https://apiupload#{@data_center}.springcm.com/v#{@api_version}"
|
43
65
|
end
|
44
66
|
|
67
|
+
# Get the URL for content download requests
|
45
68
|
def download_api_url
|
46
69
|
"https://apidownload#{@data_center}.springcm.com/v#{@api_version}"
|
47
70
|
end
|
48
71
|
|
72
|
+
# Get the URL for authentication requests
|
49
73
|
def auth_url
|
50
74
|
"https://auth#{auth_subdomain_suffix}.springcm.com/api/v#{@auth_version}/apiuser"
|
51
75
|
end
|
data/lib/springcm/version.rb
CHANGED
data/springcm-sdk.gemspec
CHANGED
@@ -9,9 +9,9 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Paul Holden"]
|
10
10
|
spec.email = ["pholden@stria.com"]
|
11
11
|
|
12
|
-
spec.summary = %q{A library
|
13
|
-
spec.description = %q{A library
|
14
|
-
spec.homepage = "https://github.com/paulholden2/springcm"
|
12
|
+
spec.summary = %q{A library for working with the SpringCM REST API.}
|
13
|
+
spec.description = %q{A library for working with the SpringCM REST API and associated objects in Ruby applications.}
|
14
|
+
spec.homepage = "https://github.com/paulholden2/springcm-sdk"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
17
17
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
@@ -20,8 +20,9 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
21
21
|
|
22
22
|
spec.metadata["homepage_uri"] = spec.homepage
|
23
|
-
spec.metadata["source_code_uri"] = "https://github.com/paulholden2/springcm"
|
24
|
-
|
23
|
+
spec.metadata["source_code_uri"] = "https://github.com/paulholden2/springcm-sdk"
|
24
|
+
spec.metadata["documentation_uri"] = "https://rubydoc.info/github/paulholden2/springcm-sdk/#{Springcm::VERSION}"
|
25
|
+
spec.metadata["changelog_uri"] = "https://github.com/paulholden2/springcm-sdk/blob/master/CHANGELOG.md"
|
25
26
|
else
|
26
27
|
raise "RubyGems 2.0 or newer is required to protect against " \
|
27
28
|
"public gem pushes."
|
@@ -43,4 +44,6 @@ Gem::Specification.new do |spec|
|
|
43
44
|
spec.add_development_dependency "rspec", "~> 3.0"
|
44
45
|
spec.add_development_dependency "sinatra", "~> 2.0"
|
45
46
|
spec.add_development_dependency "webmock", "~> 3.6"
|
47
|
+
spec.add_development_dependency "simplecov", "~> 0.17"
|
48
|
+
spec.add_development_dependency "yard", "~> 0.9"
|
46
49
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: springcm-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Holden
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -94,7 +94,36 @@ dependencies:
|
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '3.6'
|
97
|
-
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: simplecov
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0.17'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0.17'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: yard
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0.9'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0.9'
|
125
|
+
description: A library for working with the SpringCM REST API and associated objects
|
126
|
+
in Ruby applications.
|
98
127
|
email:
|
99
128
|
- pholden@stria.com
|
100
129
|
executables: []
|
@@ -105,6 +134,7 @@ files:
|
|
105
134
|
- ".gitignore"
|
106
135
|
- ".rspec"
|
107
136
|
- ".travis.yml"
|
137
|
+
- CHANGELOG.md
|
108
138
|
- Gemfile
|
109
139
|
- LICENSE.txt
|
110
140
|
- README.md
|
@@ -115,13 +145,15 @@ files:
|
|
115
145
|
- lib/springcm/client.rb
|
116
146
|
- lib/springcm/version.rb
|
117
147
|
- springcm-sdk.gemspec
|
118
|
-
homepage: https://github.com/paulholden2/springcm
|
148
|
+
homepage: https://github.com/paulholden2/springcm-sdk
|
119
149
|
licenses:
|
120
150
|
- MIT
|
121
151
|
metadata:
|
122
152
|
allowed_push_host: https://rubygems.org
|
123
|
-
homepage_uri: https://github.com/paulholden2/springcm
|
124
|
-
source_code_uri: https://github.com/paulholden2/springcm
|
153
|
+
homepage_uri: https://github.com/paulholden2/springcm-sdk
|
154
|
+
source_code_uri: https://github.com/paulholden2/springcm-sdk
|
155
|
+
documentation_uri: https://rubydoc.info/github/paulholden2/springcm-sdk/0.1.1
|
156
|
+
changelog_uri: https://github.com/paulholden2/springcm-sdk/blob/master/CHANGELOG.md
|
125
157
|
post_install_message:
|
126
158
|
rdoc_options: []
|
127
159
|
require_paths:
|
@@ -141,5 +173,5 @@ rubyforge_project:
|
|
141
173
|
rubygems_version: 2.7.7
|
142
174
|
signing_key:
|
143
175
|
specification_version: 4
|
144
|
-
summary: A library
|
176
|
+
summary: A library for working with the SpringCM REST API.
|
145
177
|
test_files: []
|