wes-data-api 9.1.0 → 10.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/lib/wes/data/api.rb +4 -4
- data/lib/wes/data/api/base.rb +2 -2
- data/lib/wes/data/api/brand.rb +3 -3
- data/lib/wes/data/api/brand_user.rb +3 -3
- data/lib/wes/data/api/{challenge.rb → brief.rb} +11 -11
- data/lib/wes/data/api/client.rb +2 -2
- data/lib/wes/data/api/collective.rb +2 -2
- data/lib/wes/data/api/configuration.rb +3 -3
- data/lib/wes/data/api/creator_user.rb +3 -3
- data/lib/wes/data/api/model/brand.rb +7 -7
- data/lib/wes/data/api/model/brand_user.rb +4 -4
- data/lib/wes/data/api/model/{challenge.rb → brief.rb} +13 -13
- data/lib/wes/data/api/model/{challenge_answer.rb → brief_answer.rb} +5 -5
- data/lib/wes/data/api/model/challenge_question.rb +2 -2
- data/lib/wes/data/api/model/collective.rb +1 -1
- data/lib/wes/data/api/model/creator_user.rb +10 -10
- data/lib/wes/data/api/model/reward.rb +3 -3
- data/lib/wes/data/api/model/submission.rb +6 -6
- data/lib/wes/data/api/model/video.rb +11 -11
- data/lib/wes/data/api/model/video_transcoding_state.rb +1 -1
- data/lib/wes/data/api/model/video_version.rb +2 -2
- data/lib/wes/data/api/request.rb +10 -10
- data/lib/wes/data/api/response.rb +3 -3
- data/lib/wes/data/api/reward.rb +2 -2
- data/lib/wes/data/api/routes.rb +18 -18
- data/lib/wes/data/api/submission.rb +3 -3
- data/lib/wes/data/api/video.rb +2 -2
- data/lib/wes/data/api/video_transcoding_state.rb +4 -4
- data/lib/wes/data/api/video_version.rb +5 -5
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe970e2592ca2579b7f87af6f76a8c90ceea8c4d
|
4
|
+
data.tar.gz: af53052eadbbebc38e288a0e84ab9759e68c6123
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04c75a496a7e71c5c54f3c45f3eeb00d4561ad6794242d77e12e044050ed52190baa846ec396908f6b04697ce845f082e06188ec654ad3a153bad6a285a77723
|
7
|
+
data.tar.gz: 04bf86ca82af8000540fbe1994c0cf712ba8d92735445dc60186157383b0b33440cc6eded9650c0aebbbe24edb3b525b5550a8bca516e411f412c1268313a495
|
data/Gemfile
CHANGED
data/lib/wes/data/api.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require 'json'
|
2
|
+
require 'ostruct'
|
3
|
+
require 'wes/data/api/configuration'
|
4
4
|
|
5
5
|
module Wes
|
6
6
|
module Data
|
7
7
|
module API
|
8
|
-
VERSION =
|
8
|
+
VERSION = '10.0.0'.freeze
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
data/lib/wes/data/api/base.rb
CHANGED
data/lib/wes/data/api/brand.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'wes/data/api/base'
|
2
|
+
require 'wes/data/api/model/brand'
|
3
3
|
|
4
4
|
module Wes
|
5
5
|
module Data
|
@@ -13,7 +13,7 @@ module Wes
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def find(_key, value)
|
16
|
-
route = [routes.brand, value].join(
|
16
|
+
route = [routes.brand, value].join('/')
|
17
17
|
attributes = client.get(route).first
|
18
18
|
attributes.nil? ? nil : model_klass.new(attributes)
|
19
19
|
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'wes/data/api/base'
|
2
|
+
require 'wes/data/api/model/brand_user'
|
3
3
|
|
4
4
|
module Wes
|
5
5
|
module Data
|
@@ -14,7 +14,7 @@ module Wes
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def find(_key, value)
|
17
|
-
route = [routes.brand_user, value].join(
|
17
|
+
route = [routes.brand_user, value].join('/')
|
18
18
|
attributes = client.get(route).first
|
19
19
|
attributes.nil? ? nil : model_klass.new(attributes)
|
20
20
|
end
|
@@ -1,23 +1,23 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require 'wes/data/api/base'
|
2
|
+
require 'wes/data/api/model/brief'
|
3
|
+
require 'wes/data/api/model/brief_question'
|
4
4
|
|
5
5
|
module Wes
|
6
6
|
module Data
|
7
7
|
module API
|
8
|
-
class
|
8
|
+
class Brief
|
9
9
|
class << self
|
10
10
|
include Base
|
11
11
|
|
12
12
|
def all(state = nil)
|
13
|
-
route = add_state(routes.
|
13
|
+
route = add_state(routes.briefs, state)
|
14
14
|
map_objects(
|
15
15
|
client.get(route), model_klass
|
16
16
|
)
|
17
17
|
end
|
18
18
|
|
19
19
|
def create(data)
|
20
|
-
attributes = client.post(routes.
|
20
|
+
attributes = client.post(routes.brief, data).first
|
21
21
|
attributes.nil? ? nil : model_klass.new(attributes)
|
22
22
|
end
|
23
23
|
|
@@ -27,9 +27,9 @@ module Wes
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def questions
|
30
|
-
route = [routes.
|
30
|
+
route = [routes.brief, routes.questions].join('/')
|
31
31
|
map_objects(
|
32
|
-
client.get(route), Wes::Data::API::Model::
|
32
|
+
client.get(route), Wes::Data::API::Model::BriefQuestion
|
33
33
|
)
|
34
34
|
end
|
35
35
|
|
@@ -38,14 +38,14 @@ module Wes
|
|
38
38
|
def find_route(key, value)
|
39
39
|
case key
|
40
40
|
when :id
|
41
|
-
[routes.
|
41
|
+
[routes.brief, value].join('/')
|
42
42
|
else
|
43
|
-
"#{routes.
|
43
|
+
"#{routes.brief}?#{key}=#{value}"
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
47
|
def model_klass
|
48
|
-
Wes::Data::API::Model::
|
48
|
+
Wes::Data::API::Model::Brief
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
data/lib/wes/data/api/client.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
|
-
require
|
1
|
+
require 'wes/data/api/routes'
|
2
2
|
|
3
3
|
module Wes
|
4
4
|
module Data
|
5
5
|
module API
|
6
6
|
class Configuration
|
7
|
-
DEFAULT_VERSION =
|
7
|
+
DEFAULT_VERSION = 'v1'.freeze
|
8
8
|
|
9
9
|
class << self
|
10
10
|
attr_accessor :endpoint, :transcoded_video_filename_suffix
|
11
11
|
attr_writer :version
|
12
12
|
|
13
|
-
def configure(&
|
13
|
+
def configure(&_block)
|
14
14
|
yield self
|
15
15
|
self
|
16
16
|
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'wes/data/api/base'
|
2
|
+
require 'wes/data/api/model/creator_user'
|
3
3
|
|
4
4
|
module Wes
|
5
5
|
module Data
|
@@ -29,7 +29,7 @@ module Wes
|
|
29
29
|
def find_route(key, value)
|
30
30
|
case key
|
31
31
|
when :id
|
32
|
-
[routes.creator_user, value].join(
|
32
|
+
[routes.creator_user, value].join('/')
|
33
33
|
else
|
34
34
|
"#{routes.creator_user}?#{key}=#{value}"
|
35
35
|
end
|
@@ -1,22 +1,22 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'wes/data/api/model/base'
|
2
|
+
require 'wes/data/api/model/brief'
|
3
3
|
|
4
4
|
module Wes
|
5
5
|
module Data
|
6
6
|
module API
|
7
7
|
module Model
|
8
8
|
class Brand < Base
|
9
|
-
def
|
10
|
-
records = fetch ?
|
9
|
+
def briefs(fetch: false)
|
10
|
+
records = fetch ? fetch_briefs : @attributes.briefs
|
11
11
|
map_objects(
|
12
|
-
records, Wes::Data::API::Model::
|
12
|
+
records, Wes::Data::API::Model::Brief
|
13
13
|
)
|
14
14
|
end
|
15
15
|
|
16
16
|
private
|
17
17
|
|
18
|
-
def
|
19
|
-
route = [routes.brand, id, routes.
|
18
|
+
def fetch_briefs
|
19
|
+
route = [routes.brand, id, routes.briefs].join('/')
|
20
20
|
client.get(route)
|
21
21
|
end
|
22
22
|
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'wes/data/api/model/base'
|
2
|
+
require 'wes/data/api/model/brand'
|
3
3
|
|
4
4
|
module Wes
|
5
5
|
module Data
|
@@ -7,7 +7,7 @@ module Wes
|
|
7
7
|
module Model
|
8
8
|
class BrandUser < Base
|
9
9
|
def update(changes)
|
10
|
-
route = [routes.brand_user, id].join(
|
10
|
+
route = [routes.brand_user, id].join('/')
|
11
11
|
@attributes = client.put(
|
12
12
|
route, @attributes.to_h.merge(changes)
|
13
13
|
).first
|
@@ -31,7 +31,7 @@ module Wes
|
|
31
31
|
private
|
32
32
|
|
33
33
|
def fetch_brands
|
34
|
-
route = [routes.brand_user, id, routes.brands].join(
|
34
|
+
route = [routes.brand_user, id, routes.brands].join('/')
|
35
35
|
client.get(route)
|
36
36
|
end
|
37
37
|
end
|
@@ -1,18 +1,18 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
1
|
+
require 'wes/data/api/model/base'
|
2
|
+
require 'wes/data/api/model/reward'
|
3
|
+
require 'wes/data/api/model/creator_user'
|
4
|
+
require 'wes/data/api/model/video'
|
5
|
+
require 'wes/data/api/model/brief_answer'
|
6
6
|
|
7
7
|
module Wes
|
8
8
|
module Data
|
9
9
|
module API
|
10
10
|
module Model
|
11
|
-
class
|
11
|
+
class Brief < Base
|
12
12
|
def answers(fetch: false)
|
13
13
|
records = fetch ? client.get(answers_route) : @attributes.answers
|
14
14
|
map_objects(
|
15
|
-
records, Wes::Data::API::Model::
|
15
|
+
records, Wes::Data::API::Model::BriefAnswer
|
16
16
|
)
|
17
17
|
end
|
18
18
|
|
@@ -40,7 +40,7 @@ module Wes
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def update(changes)
|
43
|
-
route = [routes.
|
43
|
+
route = [routes.brief, id].join('/')
|
44
44
|
@attributes = client.put(
|
45
45
|
route, @attributes.to_h.merge(changes)
|
46
46
|
).first
|
@@ -49,7 +49,7 @@ module Wes
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def update_status(s)
|
52
|
-
update(:
|
52
|
+
update(status: s)
|
53
53
|
end
|
54
54
|
|
55
55
|
def videos(state: nil, fetch: false)
|
@@ -63,24 +63,24 @@ module Wes
|
|
63
63
|
private
|
64
64
|
|
65
65
|
def answers_route
|
66
|
-
[routes.
|
66
|
+
[routes.brief, id, routes.answers].join('/')
|
67
67
|
end
|
68
68
|
|
69
69
|
def fetch_rewards
|
70
|
-
route = [routes.
|
70
|
+
route = [routes.brief, id, routes.rewards].join('/')
|
71
71
|
client.get(route)
|
72
72
|
end
|
73
73
|
|
74
74
|
def fetch_users(state)
|
75
75
|
route = add_state(
|
76
|
-
[routes.
|
76
|
+
[routes.brief, id, routes.creator_users].join('/'), state
|
77
77
|
)
|
78
78
|
client.get(route)
|
79
79
|
end
|
80
80
|
|
81
81
|
def fetch_videos(state)
|
82
82
|
route = add_state(
|
83
|
-
[routes.
|
83
|
+
[routes.brief, id, routes.videos].join('/'), state
|
84
84
|
)
|
85
85
|
client.get(route)
|
86
86
|
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
require
|
1
|
+
require 'wes/data/api/model/base'
|
2
2
|
|
3
3
|
module Wes
|
4
4
|
module Data
|
5
5
|
module API
|
6
6
|
module Model
|
7
|
-
class
|
7
|
+
class BriefAnswer < Base
|
8
8
|
def id
|
9
9
|
ids_set? ? id_hash : nil
|
10
10
|
end
|
@@ -12,13 +12,13 @@ module Wes
|
|
12
12
|
private
|
13
13
|
|
14
14
|
def ids_set?
|
15
|
-
!@attributes.
|
15
|
+
!@attributes.brief_id.nil? && !@attributes.question_id.nil?
|
16
16
|
end
|
17
17
|
|
18
18
|
def id_hash
|
19
19
|
{
|
20
|
-
|
21
|
-
|
20
|
+
'brief_id' => @attributes.brief_id,
|
21
|
+
'question_id' => @attributes.question_id
|
22
22
|
}
|
23
23
|
end
|
24
24
|
end
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
1
|
+
require 'wes/data/api/model/base'
|
2
|
+
require 'wes/data/api/model/collective'
|
3
|
+
require 'wes/data/api/model/submission'
|
4
|
+
require 'wes/data/api/model/video'
|
5
5
|
|
6
6
|
module Wes
|
7
7
|
module Data
|
@@ -17,7 +17,7 @@ module Wes
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def update(changes)
|
20
|
-
route = [routes.creator_user, id].join(
|
20
|
+
route = [routes.creator_user, id].join('/')
|
21
21
|
@attributes = client.put(
|
22
22
|
route, @attributes.to_h.merge(changes)
|
23
23
|
).first
|
@@ -42,20 +42,20 @@ module Wes
|
|
42
42
|
|
43
43
|
def create_collectives(collective_ids)
|
44
44
|
client.post(
|
45
|
-
[routes.creator_user, id, routes.collectives].join(
|
45
|
+
[routes.creator_user, id, routes.collectives].join('/'),
|
46
46
|
collective_ids
|
47
47
|
)
|
48
48
|
end
|
49
49
|
|
50
50
|
def fetch_submissions(state)
|
51
51
|
route = add_state(
|
52
|
-
[routes.creator_user, id, routes.submissions].join(
|
52
|
+
[routes.creator_user, id, routes.submissions].join('/'), state
|
53
53
|
)
|
54
54
|
client.get(route)
|
55
55
|
end
|
56
56
|
|
57
57
|
def fetch_videos
|
58
|
-
route = [routes.creator_user, id, routes.videos].join(
|
58
|
+
route = [routes.creator_user, id, routes.videos].join('/')
|
59
59
|
client.get(route)
|
60
60
|
end
|
61
61
|
|
@@ -65,9 +65,9 @@ module Wes
|
|
65
65
|
|
66
66
|
def validate_collectives(input)
|
67
67
|
unless input.is_a?(Array)
|
68
|
-
raise(ArgumentError,
|
68
|
+
raise(ArgumentError, 'List of collective IDs must be an array')
|
69
69
|
end
|
70
|
-
raise(StandardError,
|
70
|
+
raise(StandardError, 'List of collective IDs empty') if input.empty?
|
71
71
|
end
|
72
72
|
end
|
73
73
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'wes/data/api/model/base'
|
2
2
|
|
3
3
|
module Wes
|
4
4
|
module Data
|
@@ -6,12 +6,12 @@ module Wes
|
|
6
6
|
module Model
|
7
7
|
class Reward < Base
|
8
8
|
def delete
|
9
|
-
route = [routes.reward, id].join(
|
9
|
+
route = [routes.reward, id].join('/')
|
10
10
|
client.delete(route)
|
11
11
|
end
|
12
12
|
|
13
13
|
def update(changes)
|
14
|
-
route = [routes.reward, id].join(
|
14
|
+
route = [routes.reward, id].join('/')
|
15
15
|
@attributes = client.put(
|
16
16
|
route, @attributes.to_h.merge(changes)
|
17
17
|
).first
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'wes/data/api/model/base'
|
2
|
+
require 'wes/data/api/model/video'
|
3
3
|
|
4
4
|
module Wes
|
5
5
|
module Data
|
@@ -7,11 +7,11 @@ module Wes
|
|
7
7
|
module Model
|
8
8
|
class Submission < Base
|
9
9
|
def approve
|
10
|
-
update(:
|
10
|
+
update(state: 'approved')
|
11
11
|
end
|
12
12
|
|
13
13
|
def decline
|
14
|
-
update(:
|
14
|
+
update(state: 'declined')
|
15
15
|
end
|
16
16
|
|
17
17
|
def videos(fetch: false)
|
@@ -24,12 +24,12 @@ module Wes
|
|
24
24
|
private
|
25
25
|
|
26
26
|
def fetch_videos
|
27
|
-
route = [routes.submission, id, routes.videos].join(
|
27
|
+
route = [routes.submission, id, routes.videos].join('/')
|
28
28
|
client.get(route)
|
29
29
|
end
|
30
30
|
|
31
31
|
def update(changes)
|
32
|
-
route = [routes.submission, id].join(
|
32
|
+
route = [routes.submission, id].join('/')
|
33
33
|
@attributes = client.put(
|
34
34
|
route, @attributes.to_h.merge(changes)
|
35
35
|
).first
|
@@ -1,9 +1,9 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
1
|
+
require 'wes/data/api/model/base'
|
2
|
+
require 'wes/data/api/model/creator_user'
|
3
|
+
require 'wes/data/api/video_transcoding_state'
|
4
|
+
require 'wes/data/api/model/submission'
|
5
|
+
require 'wes/data/api/model/video_version'
|
6
|
+
require 'wes/data/api/submission'
|
7
7
|
|
8
8
|
module Wes
|
9
9
|
module Data
|
@@ -11,22 +11,22 @@ module Wes
|
|
11
11
|
module Model
|
12
12
|
class Video < Base
|
13
13
|
def creator_user
|
14
|
-
route = [routes.video, id, routes.creator_user].join(
|
14
|
+
route = [routes.video, id, routes.creator_user].join('/')
|
15
15
|
attributes = client.get(route).first
|
16
16
|
attributes.nil? ? nil
|
17
17
|
: Wes::Data::API::Model::CreatorUser.new(attributes)
|
18
18
|
end
|
19
19
|
|
20
20
|
def set_caption(edit)
|
21
|
-
update(:
|
21
|
+
update(caption: edit)
|
22
22
|
end
|
23
23
|
|
24
24
|
def set_state(state)
|
25
|
-
update(:
|
25
|
+
update(state: state)
|
26
26
|
end
|
27
27
|
|
28
28
|
def update(changes)
|
29
|
-
route = [routes.video, id].join(
|
29
|
+
route = [routes.video, id].join('/')
|
30
30
|
@attributes = client.put(
|
31
31
|
route, @attributes.to_h.merge(changes)
|
32
32
|
).first
|
@@ -88,7 +88,7 @@ module Wes
|
|
88
88
|
|
89
89
|
def find_transcoding_state(type)
|
90
90
|
@attributes.transcoding_states.find do |state|
|
91
|
-
state[
|
91
|
+
state['type'] == type
|
92
92
|
end
|
93
93
|
end
|
94
94
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'wes/data/api/model/base'
|
2
2
|
|
3
3
|
module Wes
|
4
4
|
module Data
|
@@ -6,7 +6,7 @@ module Wes
|
|
6
6
|
module Model
|
7
7
|
class VideoVersion < Base
|
8
8
|
def update(changes)
|
9
|
-
route = [routes.video, @attributes.video_id, routes.version, id].join(
|
9
|
+
route = [routes.video, @attributes.video_id, routes.version, id].join('/')
|
10
10
|
@attributes = client.put(
|
11
11
|
route, @attributes.to_h.merge(changes)
|
12
12
|
).first
|
data/lib/wes/data/api/request.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require 'faraday'
|
2
|
+
require 'faraday_middleware'
|
3
|
+
require 'wes/data/api/configuration'
|
4
4
|
|
5
5
|
module Wes
|
6
6
|
module Data
|
@@ -10,7 +10,7 @@ module Wes
|
|
10
10
|
def get(path)
|
11
11
|
connection.get do |r|
|
12
12
|
r.options.timeout = TIMEOUT
|
13
|
-
r.headers[
|
13
|
+
r.headers['Content-Type'] = 'application/json'
|
14
14
|
r.url complete_path(path)
|
15
15
|
end
|
16
16
|
end
|
@@ -18,7 +18,7 @@ module Wes
|
|
18
18
|
def post(path, options)
|
19
19
|
connection.post do |r|
|
20
20
|
r.body = options.to_json
|
21
|
-
r.headers[
|
21
|
+
r.headers['Content-Type'] = 'application/json'
|
22
22
|
r.options.timeout = TIMEOUT
|
23
23
|
r.url complete_path(path)
|
24
24
|
end
|
@@ -27,7 +27,7 @@ module Wes
|
|
27
27
|
def put(path, options)
|
28
28
|
connection.put do |r|
|
29
29
|
r.body = options.to_json
|
30
|
-
r.headers[
|
30
|
+
r.headers['Content-Type'] = 'application/json'
|
31
31
|
r.options.timeout = TIMEOUT
|
32
32
|
r.url complete_path(path)
|
33
33
|
end
|
@@ -36,7 +36,7 @@ module Wes
|
|
36
36
|
def delete(path)
|
37
37
|
connection.delete do |r|
|
38
38
|
r.options.timeout = TIMEOUT
|
39
|
-
r.headers[
|
39
|
+
r.headers['Content-Type'] = 'application/json'
|
40
40
|
r.url complete_path(path)
|
41
41
|
end
|
42
42
|
end
|
@@ -46,7 +46,7 @@ module Wes
|
|
46
46
|
TIMEOUT = 2
|
47
47
|
|
48
48
|
def complete_path(path)
|
49
|
-
[
|
49
|
+
['', version, path].join('/')
|
50
50
|
end
|
51
51
|
|
52
52
|
def configuration
|
@@ -54,10 +54,10 @@ module Wes
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def connection
|
57
|
-
Faraday.new(:
|
57
|
+
Faraday.new(url: endpoint) do |c|
|
58
58
|
c.adapter Faraday.default_adapter
|
59
59
|
c.use Faraday::Response::RaiseError
|
60
|
-
c.response :json, :
|
60
|
+
c.response :json, content_type: /\bjson$/
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'wes/data/api/error/unexpected'
|
2
|
+
require 'wes/data/api/error/response'
|
3
3
|
|
4
4
|
module Wes
|
5
5
|
module Data
|
@@ -27,7 +27,7 @@ module Wes
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def error_details
|
30
|
-
response.body.fetch(
|
30
|
+
response.body.fetch('Error')
|
31
31
|
end
|
32
32
|
|
33
33
|
def api_error
|
data/lib/wes/data/api/reward.rb
CHANGED
data/lib/wes/data/api/routes.rb
CHANGED
@@ -5,24 +5,24 @@ module Wes
|
|
5
5
|
class << self
|
6
6
|
def hash
|
7
7
|
OpenStruct.new(
|
8
|
-
:
|
9
|
-
:
|
10
|
-
:
|
11
|
-
:
|
12
|
-
:
|
13
|
-
:
|
14
|
-
:
|
15
|
-
:
|
16
|
-
:
|
17
|
-
:
|
18
|
-
:
|
19
|
-
:
|
20
|
-
:
|
21
|
-
:
|
22
|
-
:
|
23
|
-
:
|
24
|
-
:
|
25
|
-
:
|
8
|
+
brand: 'brand',
|
9
|
+
brand_user: 'brand-user',
|
10
|
+
brands: 'brands',
|
11
|
+
brief: 'brief',
|
12
|
+
briefs: 'briefs',
|
13
|
+
collectives: 'collectives',
|
14
|
+
creator_user: 'creator-user',
|
15
|
+
creator_users: 'creator-users',
|
16
|
+
rewards: 'rewards',
|
17
|
+
reward: 'reward',
|
18
|
+
submission: 'submission',
|
19
|
+
submissions: 'submissions',
|
20
|
+
video: 'video',
|
21
|
+
videos: 'videos',
|
22
|
+
transcoding_state: 'transcoding-state',
|
23
|
+
version: 'version',
|
24
|
+
questions: 'questions',
|
25
|
+
answers: 'answers'
|
26
26
|
)
|
27
27
|
end
|
28
28
|
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'wes/data/api/base'
|
2
|
+
require 'wes/data/api/model/submission'
|
3
3
|
|
4
4
|
module Wes
|
5
5
|
module Data
|
@@ -14,7 +14,7 @@ module Wes
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def find(_key, value)
|
17
|
-
route = [routes.submission, value].join(
|
17
|
+
route = [routes.submission, value].join('/')
|
18
18
|
attributes = client.get(route).first
|
19
19
|
attributes.nil? ? nil : model_klass.new(attributes)
|
20
20
|
end
|
data/lib/wes/data/api/video.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'wes/data/api/base'
|
2
|
+
require 'wes/data/api/model/video_transcoding_state'
|
3
3
|
|
4
4
|
module Wes
|
5
5
|
module Data
|
@@ -17,12 +17,12 @@ module Wes
|
|
17
17
|
|
18
18
|
def data(video_id, video_version_id, type)
|
19
19
|
client.get(
|
20
|
-
format(
|
20
|
+
format('%s?type=%s', route(video_id, video_version_id), type)
|
21
21
|
)
|
22
22
|
end
|
23
23
|
|
24
24
|
def route(video_id, video_version_id)
|
25
|
-
[routes.video, video_id, routes.version, video_version_id, routes.transcoding_state].join(
|
25
|
+
[routes.video, video_id, routes.version, video_version_id, routes.transcoding_state].join('/')
|
26
26
|
end
|
27
27
|
|
28
28
|
def model_klass
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'wes/data/api/base'
|
2
|
+
require 'wes/data/api/model/video'
|
3
3
|
|
4
4
|
module Wes
|
5
5
|
module Data
|
@@ -14,19 +14,19 @@ module Wes
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def find(video_id, key)
|
17
|
-
route = format(
|
17
|
+
route = format('%s/%s', route(video_id), key)
|
18
18
|
attributes = client.get(route).first
|
19
19
|
attributes.nil? ? nil : model_klass.new(attributes)
|
20
20
|
end
|
21
21
|
|
22
22
|
def current(video_id)
|
23
|
-
find(video_id,
|
23
|
+
find(video_id, 'latest')
|
24
24
|
end
|
25
25
|
|
26
26
|
private
|
27
27
|
|
28
28
|
def route(video_id)
|
29
|
-
[routes.video, video_id, routes.version].join(
|
29
|
+
[routes.video, video_id, routes.version].join('/')
|
30
30
|
end
|
31
31
|
|
32
32
|
def model_klass
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wes-data-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 10.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ''
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -120,7 +120,7 @@ files:
|
|
120
120
|
- lib/wes/data/api/base.rb
|
121
121
|
- lib/wes/data/api/brand.rb
|
122
122
|
- lib/wes/data/api/brand_user.rb
|
123
|
-
- lib/wes/data/api/
|
123
|
+
- lib/wes/data/api/brief.rb
|
124
124
|
- lib/wes/data/api/client.rb
|
125
125
|
- lib/wes/data/api/collective.rb
|
126
126
|
- lib/wes/data/api/configuration.rb
|
@@ -130,8 +130,8 @@ files:
|
|
130
130
|
- lib/wes/data/api/model/base.rb
|
131
131
|
- lib/wes/data/api/model/brand.rb
|
132
132
|
- lib/wes/data/api/model/brand_user.rb
|
133
|
-
- lib/wes/data/api/model/
|
134
|
-
- lib/wes/data/api/model/
|
133
|
+
- lib/wes/data/api/model/brief.rb
|
134
|
+
- lib/wes/data/api/model/brief_answer.rb
|
135
135
|
- lib/wes/data/api/model/challenge_question.rb
|
136
136
|
- lib/wes/data/api/model/collective.rb
|
137
137
|
- lib/wes/data/api/model/creator_user.rb
|