pmp 0.2.2 → 0.2.3
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 +4 -4
- data/.gitignore +1 -0
- data/README.md +21 -11
- data/example/permissions_result.txt +0 -2
- data/lib/pmp/collection_document.rb +1 -0
- data/lib/pmp/configuration.rb +4 -0
- data/lib/pmp/connection.rb +2 -1
- data/lib/pmp/version.rb +1 -1
- data/spec/token_spec.rb +1 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ccd9974d908a4e63fce21f4e629dba99d8ffb964
|
4
|
+
data.tar.gz: da91fd91c23b1c07091ded1f7f60d504c552e2a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e57d28e41caf69a6d76732d59d8c0f05e5e0c0c1f61551fa5df046b4c945301e988dab00724ebc868b9ff144374dc01f3d86eb1919695103ca6216bfa1b96e54
|
7
|
+
data.tar.gz: 39a229cd3c8f8f7d2fca39e3b9f7a3fc880a8d286c307af0b7b403ed389544c310e9063cd6ab898ee151ee4b76715204b95254bb11a6cdcdfc35667e1bd98bea
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,13 +1,16 @@
|
|
1
|
-
# PMP
|
1
|
+
# PMP (Public Media Platform)
|
2
2
|
|
3
3
|
[](https://travis-ci.org/PRX/pmp)
|
4
4
|
[](https://coveralls.io/r/PRX/pmp)
|
5
|
+
[](https://gemnasium.com/PRX/pmp)
|
6
|
+
[](http://badge.fury.io/rb/pmp)
|
5
7
|
|
6
|
-
Gem to make it easier to use the PMP API, which is a hypermedia API using the collection.doc+json format.
|
8
|
+
Gem to make it easier to use the PMP (Public Media Platform) API, which is a hypermedia API using the collection.doc+json format.
|
9
|
+
|
10
|
+
You can learn more about the PMP here:
|
7
11
|
|
8
12
|
https://github.com/publicmediaplatform/pmpdocs/wiki
|
9
13
|
|
10
|
-
Very big hat tip to the hyperresource gem: https://github.com/gamache/hyperresource
|
11
14
|
|
12
15
|
|
13
16
|
## Installation
|
@@ -26,11 +29,14 @@ Or install it yourself as:
|
|
26
29
|
|
27
30
|
## Usage
|
28
31
|
|
29
|
-
You
|
32
|
+
You should usually go through the `PMP::Client` as a convenience or start with a `PMP::CollectionDocument`.
|
33
|
+
|
34
|
+
Below is a basic guide, you can also [see the examples for more info](example/).
|
35
|
+
|
30
36
|
|
31
37
|
```ruby
|
32
38
|
|
33
|
-
# so you need a few things, like the endpoint, default is "https://api.pmp.io"
|
39
|
+
# so you need a few things, like the endpoint, but default is "https://api.pmp.io"
|
34
40
|
endpoint = "https://api-sandbox.pmp.io"
|
35
41
|
|
36
42
|
# and you need credentials, the gem doesn't help you create these (yet)
|
@@ -67,17 +73,21 @@ puts root.guid
|
|
67
73
|
puts root.links.keys.sort
|
68
74
|
> ["creator", "edit", "navigation", "query"]
|
69
75
|
|
76
|
+
# don't feel like getting root first? Methods on the client get passed on to root
|
77
|
+
puts pmp.links.keys.sort
|
78
|
+
> ["creator", "edit", "navigation", "query"]
|
79
|
+
|
70
80
|
# want to get the creator link?
|
71
|
-
puts
|
81
|
+
puts pmp.links["creator"]
|
72
82
|
> #<PMP::Link href="https://api-sandbox.pmp.io/docs/af676335-21df-4486-ab43-e88c1b48f026">
|
73
83
|
|
74
84
|
# get the same thing as a method
|
75
|
-
puts
|
85
|
+
puts pmp.creator
|
76
86
|
> #<PMP::Link href="https://api-sandbox.pmp.io/docs/af676335-21df-4486-ab43-e88c1b48f026">
|
77
87
|
|
78
88
|
# like the root doc itself, this is lazy loaded
|
79
89
|
# but ask for an attribute on there, and you'll get the doc loaded up
|
80
|
-
puts
|
90
|
+
puts pmp.creator.guid
|
81
91
|
|
82
92
|
#### http get request to link href occurs, loads info about the creator
|
83
93
|
> 'af676335-21df-4486-ab43-e88c1b48f026'
|
@@ -89,7 +99,6 @@ puts root.creator.guid
|
|
89
99
|
Once you have a doc, you can save or delete it like so:
|
90
100
|
|
91
101
|
```ruby
|
92
|
-
|
93
102
|
# create a new blank doc, will generatr a guid automatically if not present
|
94
103
|
doc = PMP::CollectionDocument.new()
|
95
104
|
doc.title = "this is an example, ok?"
|
@@ -119,9 +128,11 @@ doc.save
|
|
119
128
|
|
120
129
|
# never mind, delete it
|
121
130
|
doc.delete
|
131
|
+
```
|
122
132
|
|
133
|
+
# Credits
|
123
134
|
|
124
|
-
|
135
|
+
Very big hat tip to the hyperresource gem: https://github.com/gamache/hyperresource
|
125
136
|
|
126
137
|
## To Do
|
127
138
|
|
@@ -129,7 +140,6 @@ Think about integrating this lovely json schema parsing project: https://github.
|
|
129
140
|
|
130
141
|
or this one: https://github.com/hoxworth/json-schema
|
131
142
|
|
132
|
-
|
133
143
|
## Contributing
|
134
144
|
|
135
145
|
1. Fork it
|
data/lib/pmp/configuration.rb
CHANGED
@@ -13,6 +13,7 @@ module PMP
|
|
13
13
|
:client_id,
|
14
14
|
:client_secret,
|
15
15
|
:oauth_token,
|
16
|
+
:token_type,
|
16
17
|
:adapter,
|
17
18
|
:endpoint,
|
18
19
|
:user_agent,
|
@@ -31,6 +32,8 @@ module PMP
|
|
31
32
|
|
32
33
|
# The value sent in the http header for 'User-Agent' if none is set
|
33
34
|
DEFAULT_USER_AGENT = "PMP Ruby Gem #{PMP::VERSION}".freeze
|
35
|
+
|
36
|
+
DEFAULT_TOKEN_TYPE = 'Bearer'
|
34
37
|
|
35
38
|
# debug is defaulted to the ENV['DEBUG'], see below
|
36
39
|
|
@@ -76,6 +79,7 @@ module PMP
|
|
76
79
|
self.adapter = DEFAULT_ADAPTER
|
77
80
|
self.endpoint = DEFAULT_ENDPOINT
|
78
81
|
self.user_agent = DEFAULT_USER_AGENT
|
82
|
+
self.token_type = DEFAULT_TOKEN_TYPE
|
79
83
|
self.debug = ENV['DEBUG']
|
80
84
|
self
|
81
85
|
end
|
data/lib/pmp/connection.rb
CHANGED
@@ -14,6 +14,7 @@ module PMP
|
|
14
14
|
:adapter,
|
15
15
|
:ssl,
|
16
16
|
:oauth_token,
|
17
|
+
:token_type,
|
17
18
|
:basic_auth,
|
18
19
|
:user,
|
19
20
|
:password,
|
@@ -27,7 +28,7 @@ module PMP
|
|
27
28
|
if opts[:basic_auth] && opts[:user] && opts[:password]
|
28
29
|
faraday.request :basic_auth, opts[:user], opts[:password]
|
29
30
|
elsif opts[:oauth_token]
|
30
|
-
faraday.request :authorization,
|
31
|
+
faraday.request :authorization, opts[:token_type], opts[:oauth_token]
|
31
32
|
end
|
32
33
|
|
33
34
|
faraday.request :multipart
|
data/lib/pmp/version.rb
CHANGED
data/spec/token_spec.rb
CHANGED