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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fcc200de904dee53f764ca2f5e0b1bef99d5c6e7
4
- data.tar.gz: 0ffb6ce9438cefe3bfc3eed01dc1042c393dbdb8
3
+ metadata.gz: ec1bad6423f90e51dd56fa8df1840ab716fcb85d
4
+ data.tar.gz: 9ec14ad9e09190a77af0d92ac6eea04d80714455
5
5
  SHA512:
6
- metadata.gz: f65b6fbb79507b8e80082b7a9752a4b850349f6ae6c3fd4be10f2fb0d5070b727fc1997c4af6bab594dab4b3bbba14ed71316c547872ae6fdcabc3c5023a1f53
7
- data.tar.gz: 0f69db3e6c834e047f9f9fa46fee35d5fa17ae3a4f7c56b32e40ab91cd465d64fb5cdba5e10734098b8c18acf0d85f953e4b18f7b1db30534600e7a83bf9b1d8
6
+ metadata.gz: 5060249e076a5cba2bebf98b3575074a8a6f6f883382535d90d4f81ed78c3c65d17f8013e94d77d9c36cbca1654a92a2c54a62c3006fbf89b551c687f405b311
7
+ data.tar.gz: 63b1f66c392d0ff8ebb9d899996749675e84f338c490f29577b3c95d50b3c14eda49e2c01641d99e56213ef69a840651f56a6a3f85401d38d53263fdce704382
data/lib/wes/data/api.rb CHANGED
@@ -5,7 +5,7 @@ require 'wes/data/api/configuration'
5
5
  module Wes
6
6
  module Data
7
7
  module API
8
- VERSION = '11.1.0'.freeze
8
+ VERSION = '11.2.0'.freeze
9
9
  end
10
10
  end
11
11
  end
@@ -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)
@@ -5,6 +5,7 @@ module Wes
5
5
  class << self
6
6
  def hash
7
7
  OpenStruct.new(
8
+ address: 'address',
8
9
  brand: 'brand',
9
10
  brand_user: 'brand-user',
10
11
  brands: 'brands',
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.1.0
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-28 00:00:00.000000000 Z
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