citrix 0.0.0 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -0
- data/CHANGELOG.md +5 -0
- data/CONTRIBUITING.md +40 -0
- data/README.md +106 -1
- data/citrix.gemspec +5 -0
- data/lib/citrix.rb +1 -0
- data/lib/citrix/training.rb +22 -0
- data/lib/citrix/training/client.rb +38 -0
- data/lib/citrix/training/credentials.rb +27 -0
- data/lib/citrix/training/helpers/http_client.rb +33 -0
- data/lib/citrix/training/helpers/initializer.rb +13 -0
- data/lib/citrix/training/namespace/registrants.rb +107 -0
- data/lib/citrix/training/namespace/trainings.rb +91 -0
- data/lib/citrix/training/resource/registrant.rb +60 -0
- data/lib/citrix/training/resource/training.rb +67 -0
- data/lib/citrix/training/resource/training_date.rb +25 -0
- data/lib/citrix/training/serializer/registrant.rb +32 -0
- data/lib/citrix/training/serializer/training.rb +49 -0
- data/lib/citrix/training/serializer/training_date.rb +19 -0
- data/lib/citrix/version.rb +1 -1
- data/spec/citrix/training/client_spec.rb +22 -0
- data/spec/citrix/training/credentials_spec.rb +31 -0
- data/spec/citrix/training/helpers/http_client_spec.rb +54 -0
- data/spec/citrix/training/helpers/initializer_spec.rb +15 -0
- data/spec/citrix/training/namespace/registrants_spec.rb +94 -0
- data/spec/citrix/training/namespace/trainings_spec.rb +85 -0
- data/spec/citrix/training/resource/registrant_spec.rb +11 -0
- data/spec/citrix/training/resource/training_spec.rb +11 -0
- data/spec/citrix/training/serializer/registrant_spec.rb +50 -0
- data/spec/citrix/training/serializer/training_date_spec.rb +21 -0
- data/spec/citrix/training/serializer/training_spec.rb +79 -0
- data/spec/fixtures/register.json +5 -0
- data/spec/fixtures/registrant.json +10 -0
- data/spec/fixtures/registrants.json +31 -0
- data/spec/fixtures/training.json +24 -0
- data/spec/fixtures/trainings.json +26 -0
- data/spec/spec_helper.rb +94 -0
- metadata +103 -2
@@ -0,0 +1,26 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"name": "Intro to HTML, CSS and JavaScript",
|
4
|
+
"description": "Create basic webpages and sites using HTML 5, CSS3 and basic JavaScript.",
|
5
|
+
"timeZone": "",
|
6
|
+
"times": [
|
7
|
+
{
|
8
|
+
"startDate": "2014-03-26T15:00:00Z",
|
9
|
+
"endDate": "2014-03-26T23:00:00Z"
|
10
|
+
}
|
11
|
+
],
|
12
|
+
"organizers": [
|
13
|
+
{
|
14
|
+
"givenName": "Charley",
|
15
|
+
"surname": "Waters",
|
16
|
+
"email": "c.waters@test.com",
|
17
|
+
"organizerKey": "8439885694023994630"
|
18
|
+
}
|
19
|
+
],
|
20
|
+
"registrationSettings": {
|
21
|
+
"disableConfirmationEmail": false,
|
22
|
+
"disableWebRegistration": false
|
23
|
+
},
|
24
|
+
"trainingKey": "8178251407424893697"
|
25
|
+
}
|
26
|
+
]
|
data/spec/spec_helper.rb
CHANGED
@@ -1,2 +1,96 @@
|
|
1
|
+
require 'codeclimate-test-reporter'
|
2
|
+
CodeClimate::TestReporter.start
|
3
|
+
|
1
4
|
require 'bundler/setup'
|
2
5
|
require 'citrix'
|
6
|
+
require 'webmock/rspec'
|
7
|
+
|
8
|
+
require 'ostruct'
|
9
|
+
require 'pathname'
|
10
|
+
|
11
|
+
WebMock.disable_net_connect!(allow: %w{codeclimate.com})
|
12
|
+
|
13
|
+
def WebMock.requests
|
14
|
+
@requests ||= []
|
15
|
+
end
|
16
|
+
|
17
|
+
WebMock.after_request do |request, response|
|
18
|
+
WebMock.requests << request
|
19
|
+
end
|
20
|
+
|
21
|
+
RSpec.configure do |config|
|
22
|
+
config.before do
|
23
|
+
WebMock.requests.clear
|
24
|
+
$DEBUG = false
|
25
|
+
end
|
26
|
+
|
27
|
+
config.include Module.new {
|
28
|
+
def serialize(attributes, serializer = described_class)
|
29
|
+
serializer.new(attributes: attributes).serialize
|
30
|
+
end
|
31
|
+
|
32
|
+
def deserialize(attributes, serializer = described_class)
|
33
|
+
serializer.new(attributes: attributes).deserialize
|
34
|
+
end
|
35
|
+
|
36
|
+
def build_credentials(credentials = {})
|
37
|
+
Citrix::Training::Credentials.build({
|
38
|
+
oauth_token: credentials.fetch(:oauth_token, 'OAUTH_TOKEN'),
|
39
|
+
organizer_key: credentials.fetch(:organizer_key, 'ORGANIZER_KEY'),
|
40
|
+
account_key: credentials.fetch(:account_key, 'ACCOUNT_KEY')
|
41
|
+
})
|
42
|
+
end
|
43
|
+
|
44
|
+
def build_client(credentials = {})
|
45
|
+
Citrix::Training::Client.build(build_credentials(credentials))
|
46
|
+
end
|
47
|
+
|
48
|
+
def build_training_attributes(attributes = {})
|
49
|
+
{
|
50
|
+
name: 'NAME',
|
51
|
+
description: 'DESCRIPTION',
|
52
|
+
timezone: 'TIMEZONE',
|
53
|
+
web_registration: false,
|
54
|
+
confirmation_email: false,
|
55
|
+
organizers: [],
|
56
|
+
dates: [build_date]
|
57
|
+
}.merge(attributes)
|
58
|
+
end
|
59
|
+
|
60
|
+
def build_date(starts_at = Time.now, ends_at = starts_at + 3600)
|
61
|
+
Citrix::Training::Resource::TrainingDate.new(starts_at, ends_at)
|
62
|
+
end
|
63
|
+
|
64
|
+
def build_training(attributes = {})
|
65
|
+
Citrix::Training::Resource::Training.new(
|
66
|
+
build_training_attributes.merge(key: '1234').merge(attributes)
|
67
|
+
)
|
68
|
+
end
|
69
|
+
|
70
|
+
def build_registrant_attributes(attributes = {})
|
71
|
+
{
|
72
|
+
first_name: 'John',
|
73
|
+
last_name: 'Doe',
|
74
|
+
email: 'john@example.com'
|
75
|
+
}.merge(attributes)
|
76
|
+
end
|
77
|
+
|
78
|
+
def build_registrant(attributes = {})
|
79
|
+
Citrix::Training::Resource::Registrant.new(
|
80
|
+
build_registrant_attributes.merge(key: '1234').merge(attributes)
|
81
|
+
)
|
82
|
+
end
|
83
|
+
|
84
|
+
def url_for(*args)
|
85
|
+
File.join(Citrix::Training::API_ENDPOINT, *args)
|
86
|
+
end
|
87
|
+
|
88
|
+
def last_request
|
89
|
+
WebMock.requests.last
|
90
|
+
end
|
91
|
+
|
92
|
+
def fixtures
|
93
|
+
Pathname.new(File.expand_path('../fixtures', __FILE__))
|
94
|
+
end
|
95
|
+
}
|
96
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: citrix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nando Vieira
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: aitch
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,6 +66,48 @@ dependencies:
|
|
52
66
|
- - ">="
|
53
67
|
- !ruby/object:Gem::Version
|
54
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: codeclimate-test-reporter
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: webmock
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: pry-meta
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
55
111
|
description: API wrappers for Citrix services like GoToTraining.
|
56
112
|
email:
|
57
113
|
- fnando.vieira@gmail.com
|
@@ -70,7 +126,36 @@ files:
|
|
70
126
|
- Rakefile
|
71
127
|
- citrix.gemspec
|
72
128
|
- lib/citrix.rb
|
129
|
+
- lib/citrix/training.rb
|
130
|
+
- lib/citrix/training/client.rb
|
131
|
+
- lib/citrix/training/credentials.rb
|
132
|
+
- lib/citrix/training/helpers/http_client.rb
|
133
|
+
- lib/citrix/training/helpers/initializer.rb
|
134
|
+
- lib/citrix/training/namespace/registrants.rb
|
135
|
+
- lib/citrix/training/namespace/trainings.rb
|
136
|
+
- lib/citrix/training/resource/registrant.rb
|
137
|
+
- lib/citrix/training/resource/training.rb
|
138
|
+
- lib/citrix/training/resource/training_date.rb
|
139
|
+
- lib/citrix/training/serializer/registrant.rb
|
140
|
+
- lib/citrix/training/serializer/training.rb
|
141
|
+
- lib/citrix/training/serializer/training_date.rb
|
73
142
|
- lib/citrix/version.rb
|
143
|
+
- spec/citrix/training/client_spec.rb
|
144
|
+
- spec/citrix/training/credentials_spec.rb
|
145
|
+
- spec/citrix/training/helpers/http_client_spec.rb
|
146
|
+
- spec/citrix/training/helpers/initializer_spec.rb
|
147
|
+
- spec/citrix/training/namespace/registrants_spec.rb
|
148
|
+
- spec/citrix/training/namespace/trainings_spec.rb
|
149
|
+
- spec/citrix/training/resource/registrant_spec.rb
|
150
|
+
- spec/citrix/training/resource/training_spec.rb
|
151
|
+
- spec/citrix/training/serializer/registrant_spec.rb
|
152
|
+
- spec/citrix/training/serializer/training_date_spec.rb
|
153
|
+
- spec/citrix/training/serializer/training_spec.rb
|
154
|
+
- spec/fixtures/register.json
|
155
|
+
- spec/fixtures/registrant.json
|
156
|
+
- spec/fixtures/registrants.json
|
157
|
+
- spec/fixtures/training.json
|
158
|
+
- spec/fixtures/trainings.json
|
74
159
|
- spec/spec_helper.rb
|
75
160
|
homepage: https://github.com/fnando/citrix
|
76
161
|
licenses:
|
@@ -97,4 +182,20 @@ signing_key:
|
|
97
182
|
specification_version: 4
|
98
183
|
summary: API wrappers for Citrix services like GoToTraining.
|
99
184
|
test_files:
|
185
|
+
- spec/citrix/training/client_spec.rb
|
186
|
+
- spec/citrix/training/credentials_spec.rb
|
187
|
+
- spec/citrix/training/helpers/http_client_spec.rb
|
188
|
+
- spec/citrix/training/helpers/initializer_spec.rb
|
189
|
+
- spec/citrix/training/namespace/registrants_spec.rb
|
190
|
+
- spec/citrix/training/namespace/trainings_spec.rb
|
191
|
+
- spec/citrix/training/resource/registrant_spec.rb
|
192
|
+
- spec/citrix/training/resource/training_spec.rb
|
193
|
+
- spec/citrix/training/serializer/registrant_spec.rb
|
194
|
+
- spec/citrix/training/serializer/training_date_spec.rb
|
195
|
+
- spec/citrix/training/serializer/training_spec.rb
|
196
|
+
- spec/fixtures/register.json
|
197
|
+
- spec/fixtures/registrant.json
|
198
|
+
- spec/fixtures/registrants.json
|
199
|
+
- spec/fixtures/training.json
|
200
|
+
- spec/fixtures/trainings.json
|
100
201
|
- spec/spec_helper.rb
|