orcid_client 0.1.7 → 0.1.8

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
  SHA1:
3
- metadata.gz: 262b026a4b9e0dd390c03f459556f81c7ef2de0a
4
- data.tar.gz: 3760397b16157de4abe9ebb05ab4fdfb2c041615
3
+ metadata.gz: b8243d6eef5bb1d6dfbd86ed6da784a1c78459bc
4
+ data.tar.gz: 7e39fd99bbef5b60b5d6dfe2b29b071d67626e3a
5
5
  SHA512:
6
- metadata.gz: 308b88a81d942f42450874db098f850bb9e5fde6140100ba6f9ede0363201521c114249e6495ea6fcc707cca0b669fe1d5a8a04ef43ddbc823f654c97ae0d5cc
7
- data.tar.gz: 7a45a1b143a1865108d3a12900d46e5f634cc20f7c3424b2a1dfa0079730757cf711345527c017c55b407547d7a859d9348a9f906d029a1004c7ca4e94368a57
6
+ metadata.gz: 7dfe0f42fca7d00cb329983e90ddedd69d7de3d9d43363a45959e611f039b0327cf9a404a2c2236e64c14f1be3d79d193fa77356fe0b4aaf16f3ca33e1bc92c1
7
+ data.tar.gz: 1e81e0e9482e93838514e03ed222e6d58137ba3ab1a1b7dd32fb126b35c0ce8688cf5328ce47331fa61fb6ca2886588847fd223f13af9c5d804fcbc94f41bfb2
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- orcid_client (0.1.7)
4
+ orcid_client (0.1.8)
5
5
  activesupport (~> 4.2, >= 4.2.5)
6
6
  builder (~> 3.2, >= 3.2.2)
7
7
  dotenv (~> 2.1, >= 2.1.1)
@@ -5,8 +5,7 @@ module OrcidClient
5
5
  API_VERSION = "2.0_rc3"
6
6
 
7
7
  def get_works(options={})
8
- response = OpenStruct.new(body: {})
9
- return { response.body["errors"] => [{ "title" => "Access token missing" }] } unless access_token.present?
8
+ return OpenStruct.new(body: { "errors" => [{ "title" => "Access token missing" }] }) unless access_token.present?
10
9
 
11
10
  orcid_api_url = options[:sandbox] ? 'https://api.sandbox.orcid.org' : 'https://api.orcid.org'
12
11
 
@@ -15,8 +14,7 @@ module OrcidClient
15
14
  end
16
15
 
17
16
  def create_work(options={})
18
- response = OpenStruct.new(body: {})
19
- return { response.body["errors"] => [{ "title" => "Access token missing" }] } unless access_token.present?
17
+ return OpenStruct.new(body: { "errors" => [{ "title" => "Access token missing" }] }) unless access_token.present?
20
18
 
21
19
  orcid_api_url = options[:sandbox] ? 'https://api.sandbox.orcid.org' : 'https://api.orcid.org'
22
20
 
@@ -28,9 +26,8 @@ module OrcidClient
28
26
  end
29
27
 
30
28
  def update_work(options={})
31
- response = OpenStruct.new(body: {})
32
- return { response.body["errors"] => [{ "title" => "Access token missing" }] } unless access_token.present?
33
- return { response.body["errors"] => [{ "title" => "Put code missing" }] } unless put_code.present?
29
+ return OpenStruct.new(body: { "errors" => [{ "title" => "Access token missing" }] }) unless access_token.present?
30
+ return OpenStruct.new(body: { "errors" => [{ "title" => "Put code missing" }] }) unless put_code.present?
34
31
 
35
32
  orcid_api_url = options[:sandbox] ? 'https://api.sandbox.orcid.org' : 'https://api.orcid.org'
36
33
 
@@ -42,9 +39,8 @@ module OrcidClient
42
39
  end
43
40
 
44
41
  def delete_work(options={})
45
- response = OpenStruct.new(body: {})
46
- return { response.body["errors"] => [{ "title" => "Access token missing" }] } unless access_token.present?
47
- return { response.body["errors"] => [{ "title" => "Put code missing" }] } unless put_code.present?
42
+ return OpenStruct.new(body: { "errors" => [{ "title" => "Access token missing" }] }) unless access_token.present?
43
+ return OpenStruct.new(body: { "errors" => [{ "title" => "Put code missing" }] }) unless put_code.present?
48
44
 
49
45
  orcid_api_url = options[:sandbox] ? 'https://api.sandbox.orcid.org' : 'https://api.orcid.org'
50
46
 
@@ -66,8 +62,7 @@ module OrcidClient
66
62
  end
67
63
 
68
64
  def create_notification(options={})
69
- response = OpenStruct.new(body: {})
70
- return { response.body["errors"] => [{ "title" => "Notification access token missing" }] } unless notification_access_token.present?
65
+ return OpenStruct.new(body: { "errors" => [{ "title" => "Notification access token missing" }] }) unless notification_access_token.present?
71
66
 
72
67
  orcid_api_url = options[:sandbox] ? 'https://api.sandbox.orcid.org' : 'https://api.orcid.org'
73
68
 
@@ -79,9 +74,8 @@ module OrcidClient
79
74
  end
80
75
 
81
76
  def delete_notification(options={})
82
- response = OpenStruct.new(body: {})
83
- return { response.body["errors"] => [{ "title" => "Notification access token missing" }] } unless notification_access_token.present?
84
- return { response.body["errors"] => [{ "title" => "Put code missing" }] } unless put_code.present?
77
+ return OpenStruct.new(body: { "errors" => [{ "title" => "Notification access token missing" }] }) unless notification_access_token.present?
78
+ return OpenStruct.new(body: { "errors" => [{ "title" => "Put code missing" }] }) unless put_code.present?
85
79
 
86
80
  orcid_api_url = options[:sandbox] ? 'https://api.sandbox.orcid.org' : 'https://api.orcid.org'
87
81
 
@@ -91,8 +85,8 @@ module OrcidClient
91
85
 
92
86
  def get_notification(options={})
93
87
  response = OpenStruct.new(body: {})
94
- return { response.body["errors"] => [{ "title" => "Notification access token missing" }] } unless notification_access_token.present?
95
- return { response.body["errors"] => [{ "title" => "Put code missing" }] } unless put_code.present?
88
+ return OpenStruct.new(body: { "errors" => [{ "title" => "Notification access token missing" }] }) unless notification_access_token.present?
89
+ return OpenStruct.new(body: { "errors" => [{ "title" => "Put code missing" }] }) unless put_code.present?
96
90
 
97
91
  orcid_api_url = options[:sandbox] ? 'https://api.sandbox.orcid.org' : 'https://api.orcid.org'
98
92
 
@@ -1,3 +1,3 @@
1
1
  module OrcidClient
2
- VERSION = "0.1.7"
2
+ VERSION = "0.1.8"
3
3
  end
data/spec/api_spec.rb CHANGED
@@ -19,6 +19,12 @@ describe OrcidClient, vcr: true do
19
19
  expect(response.body["put_code"]).not_to be_blank
20
20
  expect(response.status).to eq(201)
21
21
  end
22
+
23
+ it 'access_token missing' do
24
+ subject = OrcidClient::Work.new(doi: doi, orcid: orcid, access_token: nil)
25
+ response = subject.create_work(sandbox: true)
26
+ expect(response.body).to eq("errors"=>[{"title"=>"Access token missing"}])
27
+ end
22
28
  end
23
29
 
24
30
  describe 'get' do
@@ -29,6 +35,12 @@ describe OrcidClient, vcr: true do
29
35
  work = works.first
30
36
  expect(work["external-ids"]).to eq("external-id"=>[{"external-id-type"=>"doi", "external-id-value"=>"10.5167/UZH-19531", "external-id-url"=>nil, "external-id-relationship"=>"SELF"}])
31
37
  end
38
+
39
+ it 'access_token missing' do
40
+ subject = OrcidClient::Work.new(doi: doi, orcid: orcid, access_token: nil)
41
+ response = subject.get_works(sandbox: true)
42
+ expect(response.body).to eq("errors"=>[{"title"=>"Access token missing"}])
43
+ end
32
44
  end
33
45
 
34
46
  describe 'put' do
@@ -37,6 +49,12 @@ describe OrcidClient, vcr: true do
37
49
  expect(response.body.fetch("data", {}).fetch("work", {}).fetch("put_code", nil)).to eq(put_code)
38
50
  expect(response.status).to eq(200)
39
51
  end
52
+
53
+ it 'access_token missing' do
54
+ subject = OrcidClient::Work.new(doi: doi, orcid: orcid, access_token: nil)
55
+ response = subject.update_work(sandbox: true)
56
+ expect(response.body).to eq("errors"=>[{"title"=>"Access token missing"}])
57
+ end
40
58
  end
41
59
 
42
60
  describe 'delete' do
@@ -46,6 +64,12 @@ describe OrcidClient, vcr: true do
46
64
  expect(response.body["errors"]).to be_nil
47
65
  expect(response.status).to eq(204)
48
66
  end
67
+
68
+ it 'access_token missing' do
69
+ subject = OrcidClient::Work.new(doi: doi, orcid: orcid, access_token: nil)
70
+ response = subject.delete_work(sandbox: true)
71
+ expect(response.body).to eq("errors"=>[{"title"=>"Access token missing"}])
72
+ end
49
73
  end
50
74
  end
51
75
 
@@ -60,6 +84,12 @@ describe OrcidClient, vcr: true do
60
84
  expect(response.body["put_code"]).not_to be_blank
61
85
  expect(response.status).to eq(201)
62
86
  end
87
+
88
+ it 'access_token missing' do
89
+ subject = OrcidClient::Notification.new(doi: doi, orcid: orcid, notification_access_token: nil)
90
+ response = subject.create_notification(sandbox: true)
91
+ expect(response.body).to eq("errors"=>[{"title"=>"Notification access token missing"}])
92
+ end
63
93
  end
64
94
 
65
95
  describe 'get' do
@@ -70,6 +100,12 @@ describe OrcidClient, vcr: true do
70
100
  expect(notification["items"]["item"]).to eq("item_type"=>"work", "item_name"=>"omniauth-orcid: v.1.1.5", "external_id"=>{"external_id_type"=>"DOI", "external_id_value"=>"10.5281/zenodo.59983"})
71
101
  expect(response.status).to eq(200)
72
102
  end
103
+
104
+ it 'access_token missing' do
105
+ subject = OrcidClient::Notification.new(doi: doi, orcid: orcid, notification_access_token: nil)
106
+ response = subject.get_notification(sandbox: true)
107
+ expect(response.body).to eq("errors"=>[{"title"=>"Notification access token missing"}])
108
+ end
73
109
  end
74
110
 
75
111
  describe 'delete' do
@@ -80,6 +116,12 @@ describe OrcidClient, vcr: true do
80
116
  expect(notification["items"]["item"]).to eq("item_type"=>"work", "item_name"=>"omniauth-orcid: v.1.1.5", "external_id"=>{"external_id_type"=>"DOI", "external_id_value"=>"10.5281/zenodo.59983"})
81
117
  expect(response.status).to eq(200)
82
118
  end
119
+
120
+ it 'access_token missing' do
121
+ subject = OrcidClient::Notification.new(doi: doi, orcid: orcid, notification_access_token: nil)
122
+ response = subject.delete_notification(sandbox: true)
123
+ expect(response.body).to eq("errors"=>[{"title"=>"Notification access token missing"}])
124
+ end
83
125
  end
84
126
  end
85
127
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: orcid_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Fenner