wes-data-api 3.2.0 → 3.3.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/lib/wes/data/api/base.rb +82 -0
- data/lib/wes/data/api/billing.rb +6 -52
- data/lib/wes/data/api/challenge.rb +10 -51
- data/lib/wes/data/api/user.rb +14 -51
- data/lib/wes/data/api/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 36a4a4b4c62efac5afee29df5ba290bb91462d30
|
4
|
+
data.tar.gz: 12282a6060e9570f5053915b1a274e42b28055f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11981dba3e27067f08598096a4512ba7a65cecbb43c8b7f5ae2f57fdc99ea0f04d88a631d5bc9d9861f5d16c1217e317f0757abb0288c871b44125649a8f7658
|
7
|
+
data.tar.gz: 1d79e4cbe105c0cd977e4a6dfa7a5c2b2ee88202c8381796b716d31d5aef9224d626803485f595bf98fb06300687b8fe3a80bb093b02b4425f7e25b5fdfaa23b
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require "wes/data/api/client"
|
2
|
+
require "wes/data/api/configuration"
|
3
|
+
|
4
|
+
module Wes
|
5
|
+
module Data
|
6
|
+
module API
|
7
|
+
class Base
|
8
|
+
attr_reader :attributes
|
9
|
+
|
10
|
+
def initialize(attributes)
|
11
|
+
@attributes = attributes
|
12
|
+
end
|
13
|
+
|
14
|
+
class << self
|
15
|
+
def client
|
16
|
+
Client.new
|
17
|
+
end
|
18
|
+
|
19
|
+
def configuration
|
20
|
+
Configuration
|
21
|
+
end
|
22
|
+
|
23
|
+
def find(route)
|
24
|
+
new(client.get(route).first)
|
25
|
+
end
|
26
|
+
|
27
|
+
def create(route, payload = {})
|
28
|
+
new(client.post(route, payload).first)
|
29
|
+
end
|
30
|
+
|
31
|
+
def routes
|
32
|
+
configuration.routes
|
33
|
+
end
|
34
|
+
|
35
|
+
def mapped_objects(route)
|
36
|
+
client.get(route).map do |item|
|
37
|
+
new(item)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def exist?
|
43
|
+
!attributes.nil?
|
44
|
+
end
|
45
|
+
|
46
|
+
def method_missing(method_sym)
|
47
|
+
attributes.to_h.fetch(method_sym, nil)
|
48
|
+
end
|
49
|
+
|
50
|
+
def update(route, changes)
|
51
|
+
@attributes = client.put(
|
52
|
+
route,
|
53
|
+
@attributes.to_h.merge(changes)
|
54
|
+
).first
|
55
|
+
self
|
56
|
+
end
|
57
|
+
|
58
|
+
protected
|
59
|
+
|
60
|
+
def id_set?
|
61
|
+
raise(ArgumentError, "ID not set for #{self.class.name}") if id.nil?
|
62
|
+
end
|
63
|
+
|
64
|
+
def id
|
65
|
+
attributes.id
|
66
|
+
end
|
67
|
+
|
68
|
+
def client
|
69
|
+
self.class.client
|
70
|
+
end
|
71
|
+
|
72
|
+
def routes
|
73
|
+
self.class.routes
|
74
|
+
end
|
75
|
+
|
76
|
+
def mapped_objects(route)
|
77
|
+
self.class.mapped_objects(route)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
data/lib/wes/data/api/billing.rb
CHANGED
@@ -1,73 +1,27 @@
|
|
1
|
-
require "wes/data/api/
|
2
|
-
require "wes/data/api/configuration"
|
1
|
+
require "wes/data/api/base"
|
3
2
|
|
4
3
|
module Wes
|
5
4
|
module Data
|
6
5
|
module API
|
7
|
-
class Billing
|
8
|
-
attr_reader :attributes
|
9
|
-
|
10
|
-
def initialize(attributes)
|
11
|
-
@attributes = attributes
|
12
|
-
end
|
13
|
-
|
6
|
+
class Billing < Base
|
14
7
|
class << self
|
15
|
-
def client
|
16
|
-
Client.new
|
17
|
-
end
|
18
|
-
|
19
|
-
def configuration
|
20
|
-
Configuration
|
21
|
-
end
|
22
|
-
|
23
8
|
def create(data)
|
24
9
|
attributes = client.post("#{routes.billing}", data).first
|
25
10
|
new(attributes)
|
26
11
|
end
|
27
12
|
|
28
13
|
def find(key, value)
|
29
|
-
|
14
|
+
case key
|
30
15
|
when :id
|
31
|
-
|
16
|
+
super("#{routes.billing}/#{value}")
|
32
17
|
when :user_id
|
33
|
-
|
18
|
+
super("#{routes.user}/#{value}/billing")
|
34
19
|
end
|
35
|
-
new(attrs.first)
|
36
20
|
end
|
37
|
-
|
38
|
-
def routes
|
39
|
-
configuration.routes
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def exist?
|
44
|
-
!@attributes.nil?
|
45
|
-
end
|
46
|
-
|
47
|
-
def method_missing(method_sym)
|
48
|
-
attributes.send method_sym
|
49
21
|
end
|
50
22
|
|
51
23
|
def update(changes)
|
52
|
-
|
53
|
-
"#{routes.billing}/#{id}",
|
54
|
-
@attributes.to_h.merge(changes)
|
55
|
-
).first
|
56
|
-
self
|
57
|
-
end
|
58
|
-
|
59
|
-
private
|
60
|
-
|
61
|
-
def client
|
62
|
-
self.class.client
|
63
|
-
end
|
64
|
-
|
65
|
-
def id
|
66
|
-
attributes.id
|
67
|
-
end
|
68
|
-
|
69
|
-
def routes
|
70
|
-
self.class.routes
|
24
|
+
super("#{routes.billing}/#{id}", changes)
|
71
25
|
end
|
72
26
|
end
|
73
27
|
end
|
@@ -1,86 +1,45 @@
|
|
1
|
-
require "wes/data/api/
|
2
|
-
require "wes/data/api/configuration"
|
1
|
+
require "wes/data/api/base"
|
3
2
|
|
4
3
|
module Wes
|
5
4
|
module Data
|
6
5
|
module API
|
7
|
-
class Challenge
|
8
|
-
attr_reader :attributes
|
9
|
-
|
10
|
-
def initialize(attributes)
|
11
|
-
@attributes = attributes
|
12
|
-
end
|
6
|
+
class Challenge < Base
|
13
7
|
|
14
8
|
class << self
|
15
|
-
def client
|
16
|
-
Client.new
|
17
|
-
end
|
18
|
-
|
19
|
-
def configuration
|
20
|
-
Configuration
|
21
|
-
end
|
22
|
-
|
23
9
|
def find(id)
|
24
|
-
|
25
|
-
new(attributes)
|
10
|
+
super("#{routes.challenge}/#{id}")
|
26
11
|
end
|
27
12
|
|
28
13
|
def all
|
29
|
-
|
14
|
+
mapped_objects(routes.challenges)
|
30
15
|
end
|
31
16
|
|
32
17
|
def closed
|
33
|
-
|
18
|
+
mapped_objects("#{routes.challenges}/closed")
|
34
19
|
end
|
35
20
|
|
36
21
|
def drafts
|
37
|
-
|
22
|
+
mapped_objects("#{routes.challenges}/drafts")
|
38
23
|
end
|
39
24
|
|
40
25
|
def open
|
41
|
-
|
42
|
-
end
|
43
|
-
|
44
|
-
def routes
|
45
|
-
configuration.routes
|
26
|
+
mapped_objects("#{routes.challenges}/open")
|
46
27
|
end
|
47
28
|
end
|
48
29
|
|
49
30
|
def videos
|
50
31
|
id_set?
|
51
|
-
|
32
|
+
mapped_objects("#{routes.challenge}/#{id}#{routes.videos}")
|
52
33
|
end
|
53
34
|
|
54
35
|
def purchased_videos
|
55
36
|
id_set?
|
56
|
-
|
37
|
+
mapped_objects("#{routes.challenge}/#{id}#{routes.videos}/purchased")
|
57
38
|
end
|
58
39
|
|
59
40
|
def rewards
|
60
41
|
id_set?
|
61
|
-
|
62
|
-
end
|
63
|
-
|
64
|
-
def method_missing(method_sym)
|
65
|
-
attributes.to_h.fetch(method_sym, nil)
|
66
|
-
end
|
67
|
-
|
68
|
-
private
|
69
|
-
|
70
|
-
def id_set?
|
71
|
-
raise(ArgumentError, "ID not set for Challenge") if id.nil?
|
72
|
-
end
|
73
|
-
|
74
|
-
def client
|
75
|
-
self.class.client
|
76
|
-
end
|
77
|
-
|
78
|
-
def id
|
79
|
-
attributes.id
|
80
|
-
end
|
81
|
-
|
82
|
-
def routes
|
83
|
-
self.class.routes
|
42
|
+
mapped_objects("#{routes.challenge}/#{id}/rewards")
|
84
43
|
end
|
85
44
|
end
|
86
45
|
end
|
data/lib/wes/data/api/user.rb
CHANGED
@@ -1,71 +1,42 @@
|
|
1
|
-
require "wes/data/api/
|
2
|
-
require "wes/data/api/configuration"
|
1
|
+
require "wes/data/api/base"
|
3
2
|
|
4
3
|
module Wes
|
5
4
|
module Data
|
6
5
|
module API
|
7
|
-
class User
|
8
|
-
attr_reader :attributes
|
9
|
-
|
10
|
-
def initialize(attributes)
|
11
|
-
@attributes = attributes
|
12
|
-
end
|
13
|
-
|
6
|
+
class User < Base
|
14
7
|
class << self
|
15
|
-
def client
|
16
|
-
Client.new
|
17
|
-
end
|
18
|
-
|
19
|
-
def configuration
|
20
|
-
Configuration
|
21
|
-
end
|
22
|
-
|
23
8
|
def create(id)
|
24
|
-
|
25
|
-
new(attributes)
|
9
|
+
super("#{routes.user}/#{id}")
|
26
10
|
end
|
27
11
|
|
28
12
|
def find(key, value)
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
configuration.routes
|
13
|
+
case key
|
14
|
+
when :id
|
15
|
+
super("#{routes.user}/#{value}")
|
16
|
+
else
|
17
|
+
super("#{routes.user}?#{key}=#{value}")
|
18
|
+
end
|
36
19
|
end
|
37
20
|
end
|
38
21
|
|
39
22
|
def closed_submissions
|
40
|
-
|
41
|
-
end
|
42
|
-
|
43
|
-
def exist?
|
44
|
-
!@attributes.nil?
|
45
|
-
end
|
46
|
-
|
47
|
-
def method_missing(method_sym)
|
48
|
-
attributes.send method_sym
|
23
|
+
mapped_objects("#{routes.user}/#{id}#{routes.submissions}/closed")
|
49
24
|
end
|
50
25
|
|
51
26
|
def open_submissions
|
52
|
-
|
27
|
+
mapped_objects("#{routes.user}/#{id}#{routes.submissions}/open")
|
53
28
|
end
|
54
29
|
|
55
30
|
def submissions
|
56
|
-
|
31
|
+
mapped_objects("#{routes.user}/#{id}#{routes.submissions}")
|
57
32
|
end
|
58
33
|
|
59
34
|
def videos
|
60
|
-
|
35
|
+
mapped_objects("#{routes.user}/#{id}#{routes.videos}")
|
61
36
|
end
|
62
37
|
|
63
38
|
def update(changes)
|
64
|
-
|
65
|
-
"#{routes.user}/#{id}",
|
66
|
-
@attributes.to_h.merge(changes)
|
67
|
-
).first
|
68
|
-
self
|
39
|
+
super("#{routes.user}/#{id}", changes)
|
69
40
|
end
|
70
41
|
|
71
42
|
def assign_collectives(collective_ids)
|
@@ -85,17 +56,9 @@ module Wes
|
|
85
56
|
|
86
57
|
private
|
87
58
|
|
88
|
-
def client
|
89
|
-
self.class.client
|
90
|
-
end
|
91
|
-
|
92
59
|
def id
|
93
60
|
attributes.auth0_id
|
94
61
|
end
|
95
|
-
|
96
|
-
def routes
|
97
|
-
self.class.routes
|
98
|
-
end
|
99
62
|
end
|
100
63
|
end
|
101
64
|
end
|
data/lib/wes/data/api/version.rb
CHANGED
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: 3.
|
4
|
+
version: 3.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ''
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -117,6 +117,7 @@ extra_rdoc_files: []
|
|
117
117
|
files:
|
118
118
|
- Gemfile
|
119
119
|
- lib/wes/data/api.rb
|
120
|
+
- lib/wes/data/api/base.rb
|
120
121
|
- lib/wes/data/api/billing.rb
|
121
122
|
- lib/wes/data/api/brand.rb
|
122
123
|
- lib/wes/data/api/challenge.rb
|