wes-data-api 1.7.0 → 2.0.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: 7504ca79750d4d10e2e691eb6400d284e883f790
4
- data.tar.gz: 8e13e001807f8b68fbf070c27c6bcf60467c23ba
3
+ metadata.gz: ce69c6c00f48474db5b1f3701ce160cbdd5272bb
4
+ data.tar.gz: 1f8b5363e01e94be41c15d620103a2e884f87a0d
5
5
  SHA512:
6
- metadata.gz: a778fe44839f2106e31fb56959b1c10288217e3e89a5143eca714ed2ca14ea96bf85b43eaa60094030b937c2f2f2deb8eb0e1a36289ef40a09bfce8e55879f8e
7
- data.tar.gz: 1e2985e5d3ccdfbc86af7f85f60e62e8d62a0040955e6cd80b26c6324003209eb6d6d1e1c0dd0a5ff16e11c8b667af902ead61e533ab5fb79a382e9412b7ae4a
6
+ metadata.gz: 23d59de2b08b9024de438cd4f94cdd8f40582102542e0887661bee06395bb333df001bb0a4b2f6217467c38bef3f54e002ff4e50ff71d0de4cc83ff86a93d878
7
+ data.tar.gz: 94b70c47e1a653ba642f3814a6bd5d7bc590593ede28076adb0da49455e6a1cfad2d0522d8d37f9e4c89b3a7ca2c1a36c8d284f7a892db1e6618a15b44cf5d89
@@ -5,74 +5,76 @@ module Wes
5
5
  module Data
6
6
  module API
7
7
  class User
8
- def initialize(id = nil)
9
- @id = id
8
+ attr_reader :attributes
9
+
10
+ def initialize(attributes)
11
+ @attributes = attributes
10
12
  end
11
13
 
12
- def self.find_by_attribute(key, value)
13
- new.find_by_attribute(key, value)
14
+ class << self
15
+ def client
16
+ Client.new
17
+ end
18
+
19
+ def configuration
20
+ Configuration
21
+ end
22
+
23
+ def create(id)
24
+ attributes = client.post("#{routes.user}/#{id}", {}).first
25
+ new(attributes)
26
+ end
27
+
28
+ def find(key, value)
29
+ attrs = key == :id ? client.get("#{routes.user}/#{value}")
30
+ : client.get("#{routes.user}?#{key}=#{value}")
31
+ new(attrs.first)
32
+ end
33
+
34
+ def routes
35
+ configuration.routes
36
+ end
14
37
  end
15
38
 
16
39
  def closed_submissions
17
- check_for_id!
18
40
  client.get "#{routes.user}/#{id}#{routes.submissions}/closed"
19
41
  end
20
42
 
21
- def create_metadata
22
- check_for_id!
23
- client.post("#{routes.user}/#{id}#{routes.metadata}", {})
24
- end
25
-
26
- def find_by_attribute(key, value)
27
- client.get("#{routes.user}#{routes.metadata}?#{key}=#{value}")
28
- end
29
-
30
- def metadata
31
- check_for_id!
32
- client.get "#{routes.user}/#{id}#{routes.metadata}"
43
+ def method_missing(method_sym)
44
+ attributes.send method_sym
33
45
  end
34
46
 
35
47
  def open_submissions
36
- check_for_id!
37
- client.get "#{routes.user}/#{id}#{routes.submissions}/open"
48
+ client.get("#{routes.user}/#{id}#{routes.submissions}/open")
38
49
  end
39
50
 
40
51
  def submissions
41
- check_for_id!
42
- client.get "#{routes.user}/#{id}#{routes.submissions}"
52
+ client.get("#{routes.user}/#{id}#{routes.submissions}")
43
53
  end
44
54
 
45
- def update_metadata(new_metadata)
46
- check_for_id!
47
- client.put(
48
- "#{routes.user}/#{id}#{routes.metadata}",
49
- metadata.first.to_h.merge(new_metadata)
50
- ).first
55
+ def videos
56
+ client.get("#{routes.user}/#{id}#{routes.videos}")
51
57
  end
52
58
 
53
- def videos
54
- check_for_id!
55
- client.get "#{routes.user}/#{id}#{routes.videos}"
59
+ def update(changes)
60
+ @attributes = client.put(
61
+ "#{routes.user}/#{id}",
62
+ @attributes.to_h.merge(changes)
63
+ ).first
56
64
  end
57
65
 
58
66
  private
59
67
 
60
- attr_reader :id
61
-
62
- def check_for_id!
63
- raise(ArgumentError, "ID not set for User") if id.nil?
64
- end
65
-
66
68
  def client
67
- Client.new
69
+ self.class.client
68
70
  end
69
71
 
70
- def configuration
71
- Configuration
72
+ def id
73
+ attributes.auth0_id
72
74
  end
73
75
 
74
76
  def routes
75
- configuration.routes
77
+ self.class.routes
76
78
  end
77
79
  end
78
80
  end
@@ -1,7 +1,7 @@
1
1
  module Wes
2
2
  module Data
3
3
  module API
4
- VERSION = "1.7.0".freeze
4
+ VERSION = "2.0.0".freeze
5
5
  end
6
6
  end
7
7
  end
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: 1.7.0
4
+ version: 2.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-04-11 00:00:00.000000000 Z
11
+ date: 2016-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler