rdstation-ruby-client 0.1.1 → 1.0.0
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/Gemfile.lock +12 -12
- data/README.md +13 -13
- data/lib/rdstation-ruby-client.rb +11 -4
- data/lib/rdstation/authentication.rb +34 -21
- data/lib/rdstation/contacts.rb +26 -14
- data/lib/rdstation/error.rb +21 -0
- data/lib/rdstation/error_handler.rb +38 -0
- data/lib/rdstation/error_handler/conflicting_field.rb +26 -0
- data/lib/rdstation/error_handler/default.rb +19 -0
- data/lib/rdstation/error_handler/expired_access_token.rb +30 -0
- data/lib/rdstation/error_handler/expired_code_grant.rb +27 -0
- data/lib/rdstation/error_handler/invalid_credentials.rb +26 -0
- data/lib/rdstation/error_handler/resource_not_found.rb +26 -0
- data/lib/rdstation/error_handler/unauthorized.rb +26 -0
- data/lib/rdstation/fields.rb +26 -0
- data/lib/rdstation/version.rb +1 -1
- data/rdstation-ruby-client.gemspec +1 -2
- data/spec/lib/rdstation/authentication_spec.rb +177 -0
- data/spec/lib/rdstation/contacts_spec.rb +434 -0
- data/spec/lib/rdstation/fields_spec.rb +52 -0
- data/spec/spec_helper.rb +1 -13
- metadata +22 -20
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe RDStation::Fields do
|
4
|
+
let(:valid_auth_token) { 'valid_auth_token' }
|
5
|
+
let(:rdstation_fields_with_valid_token) { described_class.new(valid_auth_token) }
|
6
|
+
|
7
|
+
let(:valid_headers) do
|
8
|
+
{
|
9
|
+
'Authorization' => "Bearer #{valid_auth_token}",
|
10
|
+
'Content-Type' => 'application/json'
|
11
|
+
}
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#all' do
|
15
|
+
let(:fields_endpoint) { 'https://api.rd.services/platform/contacts/fields' }
|
16
|
+
let(:all_account_fields) do
|
17
|
+
{
|
18
|
+
'fields' => [
|
19
|
+
{
|
20
|
+
'uuid' => 'fdeba6ec-f1cf-4b13-b2ea-e93d47c0d828',
|
21
|
+
'api_identifier' => 'name',
|
22
|
+
'custom_field' => false,
|
23
|
+
'data_type' => 'STRING',
|
24
|
+
'name' => {
|
25
|
+
'default' => 'nome',
|
26
|
+
'pt-BR' => 'nome'
|
27
|
+
},
|
28
|
+
'label' => {
|
29
|
+
'default' => 'Nome completo',
|
30
|
+
'pt-BR' => 'Nome completo'
|
31
|
+
},
|
32
|
+
'presentation_type' => 'TEXT_INPUT',
|
33
|
+
'validation_rules' => {}
|
34
|
+
}
|
35
|
+
]
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'with a valid auth token' do
|
40
|
+
before do
|
41
|
+
stub_request(:get, fields_endpoint)
|
42
|
+
.with(headers: valid_headers)
|
43
|
+
.to_return(status: 200, body: all_account_fields.to_json)
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'returns all account fields' do
|
47
|
+
fields = rdstation_fields_with_valid_token.all
|
48
|
+
expect(fields).to eq(all_account_fields)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,14 +1,2 @@
|
|
1
1
|
require 'rdstation-ruby-client'
|
2
|
-
require '
|
3
|
-
|
4
|
-
VCR.configure do |c|
|
5
|
-
c.cassette_library_dir = 'spec/cassettes'
|
6
|
-
c.hook_into :webmock
|
7
|
-
c.configure_rspec_metadata!
|
8
|
-
end
|
9
|
-
|
10
|
-
# RSpec.configure do |c|
|
11
|
-
# # so we can use :vcr rather than :vcr => true;
|
12
|
-
# # in RSpec 3 this will no longer be necessary.
|
13
|
-
# c.treat_symbols_as_metadata_keys_with_true_values = true
|
14
|
-
# end
|
2
|
+
require 'webmock/rspec'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rdstation-ruby-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paulo L F Casaretto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-07-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,34 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: vcr
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: webmock
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
72
58
|
requirements:
|
73
|
-
- - "
|
59
|
+
- - "~>"
|
74
60
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
61
|
+
version: '2.1'
|
76
62
|
type: :development
|
77
63
|
prerelease: false
|
78
64
|
version_requirements: !ruby/object:Gem::Requirement
|
79
65
|
requirements:
|
80
|
-
- - "
|
66
|
+
- - "~>"
|
81
67
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
68
|
+
version: '2.1'
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
70
|
name: turn
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -125,9 +111,22 @@ files:
|
|
125
111
|
- lib/rdstation/authentication.rb
|
126
112
|
- lib/rdstation/client.rb
|
127
113
|
- lib/rdstation/contacts.rb
|
114
|
+
- lib/rdstation/error.rb
|
115
|
+
- lib/rdstation/error_handler.rb
|
116
|
+
- lib/rdstation/error_handler/conflicting_field.rb
|
117
|
+
- lib/rdstation/error_handler/default.rb
|
118
|
+
- lib/rdstation/error_handler/expired_access_token.rb
|
119
|
+
- lib/rdstation/error_handler/expired_code_grant.rb
|
120
|
+
- lib/rdstation/error_handler/invalid_credentials.rb
|
121
|
+
- lib/rdstation/error_handler/resource_not_found.rb
|
122
|
+
- lib/rdstation/error_handler/unauthorized.rb
|
123
|
+
- lib/rdstation/fields.rb
|
128
124
|
- lib/rdstation/version.rb
|
129
125
|
- rdstation-ruby-client.gemspec
|
130
126
|
- spec/lib/rdstation-ruby-client_spec.rb
|
127
|
+
- spec/lib/rdstation/authentication_spec.rb
|
128
|
+
- spec/lib/rdstation/contacts_spec.rb
|
129
|
+
- spec/lib/rdstation/fields_spec.rb
|
131
130
|
- spec/spec_helper.rb
|
132
131
|
homepage: http://resultadosdigitais.com.br
|
133
132
|
licenses:
|
@@ -155,4 +154,7 @@ specification_version: 4
|
|
155
154
|
summary: Ruby API wrapper for RD Station
|
156
155
|
test_files:
|
157
156
|
- spec/lib/rdstation-ruby-client_spec.rb
|
157
|
+
- spec/lib/rdstation/authentication_spec.rb
|
158
|
+
- spec/lib/rdstation/contacts_spec.rb
|
159
|
+
- spec/lib/rdstation/fields_spec.rb
|
158
160
|
- spec/spec_helper.rb
|