wes-data-api 11.1.0 → 11.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/wes/data/api.rb +1 -1
- data/lib/wes/data/api/address.rb +28 -0
- data/lib/wes/data/api/model/address.rb +27 -0
- data/lib/wes/data/api/model/base.rb +4 -4
- data/lib/wes/data/api/model/creator_user.rb +12 -0
- data/lib/wes/data/api/routes.rb +1 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec1bad6423f90e51dd56fa8df1840ab716fcb85d
|
4
|
+
data.tar.gz: 9ec14ad9e09190a77af0d92ac6eea04d80714455
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5060249e076a5cba2bebf98b3575074a8a6f6f883382535d90d4f81ed78c3c65d17f8013e94d77d9c36cbca1654a92a2c54a62c3006fbf89b551c687f405b311
|
7
|
+
data.tar.gz: 63b1f66c392d0ff8ebb9d899996749675e84f338c490f29577b3c95d50b3c14eda49e2c01641d99e56213ef69a840651f56a6a3f85401d38d53263fdce704382
|
data/lib/wes/data/api.rb
CHANGED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'wes/data/api/base'
|
2
|
+
require 'wes/data/api/model/creator_user'
|
3
|
+
|
4
|
+
module Wes
|
5
|
+
module Data
|
6
|
+
module API
|
7
|
+
class Address
|
8
|
+
class << self
|
9
|
+
include Base
|
10
|
+
|
11
|
+
def create(data, user_id)
|
12
|
+
route = [
|
13
|
+
routes.creator_user, user_id, routes.address
|
14
|
+
].join('/')
|
15
|
+
attributes = client.post(route, data).first
|
16
|
+
attributes.nil? ? nil : model_klass.new(attributes)
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def model_klass
|
22
|
+
Wes::Data::API::Model::Address
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'wes/data/api/model/base'
|
2
|
+
|
3
|
+
module Wes
|
4
|
+
module Data
|
5
|
+
module API
|
6
|
+
module Model
|
7
|
+
class Address < Base
|
8
|
+
def update(changes)
|
9
|
+
route = [
|
10
|
+
routes.creator_user, creator_auth0_id, routes.address
|
11
|
+
].join('/')
|
12
|
+
|
13
|
+
@attributes = client.put(
|
14
|
+
route, @attributes.to_h.merge(changes)
|
15
|
+
).first
|
16
|
+
|
17
|
+
self
|
18
|
+
end
|
19
|
+
|
20
|
+
def id
|
21
|
+
attributes.creator_auth0_id
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -5,10 +5,10 @@ module Wes
|
|
5
5
|
class Base
|
6
6
|
attr_reader :attributes
|
7
7
|
|
8
|
-
def initialize(attrs)
|
8
|
+
def initialize(attrs, check_id_set = true)
|
9
9
|
@attributes = attrs.is_a?(Hash) ? OpenStruct.new(attrs)
|
10
10
|
: attrs
|
11
|
-
id_set?
|
11
|
+
id_set? if check_id_set
|
12
12
|
end
|
13
13
|
|
14
14
|
def exist?
|
@@ -34,8 +34,8 @@ module Wes
|
|
34
34
|
Configuration
|
35
35
|
end
|
36
36
|
|
37
|
-
def map_objects(records, klass)
|
38
|
-
records.map { |r| klass.new(r) }
|
37
|
+
def map_objects(records, klass, args = [])
|
38
|
+
records.map { |r| klass.new(*args.unshift(r)) }
|
39
39
|
end
|
40
40
|
|
41
41
|
def method_missing(sym, *_args, &_block)
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'wes/data/api/model/base'
|
2
2
|
require 'wes/data/api/model/collective'
|
3
3
|
require 'wes/data/api/model/submission'
|
4
|
+
require 'wes/data/api/model/address'
|
4
5
|
require 'wes/data/api/model/video'
|
5
6
|
|
6
7
|
module Wes
|
@@ -8,6 +9,17 @@ module Wes
|
|
8
9
|
module API
|
9
10
|
module Model
|
10
11
|
class CreatorUser < Base
|
12
|
+
def address(fetch: false)
|
13
|
+
route = [
|
14
|
+
routes.creator_user, id, routes.address
|
15
|
+
].join('/')
|
16
|
+
|
17
|
+
records = fetch ? client.get(route) : @attributes.addresses
|
18
|
+
map_objects(
|
19
|
+
records, Wes::Data::API::Model::Address, [false]
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
11
23
|
def assign_collectives(collective_ids)
|
12
24
|
validate_collectives(collective_ids)
|
13
25
|
records = create_collectives(collective_ids)
|
data/lib/wes/data/api/routes.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: 11.
|
4
|
+
version: 11.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ''
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-31 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/address.rb
|
120
121
|
- lib/wes/data/api/base.rb
|
121
122
|
- lib/wes/data/api/brand.rb
|
122
123
|
- lib/wes/data/api/brand_user.rb
|
@@ -127,6 +128,7 @@ files:
|
|
127
128
|
- lib/wes/data/api/creator_user.rb
|
128
129
|
- lib/wes/data/api/error/response.rb
|
129
130
|
- lib/wes/data/api/error/unexpected.rb
|
131
|
+
- lib/wes/data/api/model/address.rb
|
130
132
|
- lib/wes/data/api/model/base.rb
|
131
133
|
- lib/wes/data/api/model/brand.rb
|
132
134
|
- lib/wes/data/api/model/brand_user.rb
|