timekit 0.2.3 → 0.2.5
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/active_rest/api_model.rb +5 -0
- data/lib/active_rest/concrete_example_model.rb +4 -0
- data/lib/active_rest/other_model.rb +4 -0
- data/lib/base.rb +146 -0
- data/lib/timekit.rb +4 -1
- data/lib/timekit/app.rb +1 -0
- data/lib/timekit/app/client.rb +1 -0
- data/lib/timekit/authorization.rb +1 -0
- data/lib/timekit/booking.rb +1 -0
- data/lib/timekit/booking/client.rb +1 -0
- data/lib/timekit/calendar.rb +1 -0
- data/lib/timekit/calendar/client.rb +1 -0
- data/lib/timekit/client.rb +2 -1
- data/lib/timekit/config.rb +4 -3
- data/lib/timekit/credential.rb +1 -0
- data/lib/timekit/credential/client.rb +1 -0
- data/lib/timekit/event.rb +1 -0
- data/lib/timekit/event/client.rb +13 -12
- data/lib/timekit/filtercollection.rb +3 -2
- data/lib/timekit/findtime.rb +1 -0
- data/lib/timekit/findtime/client.rb +6 -5
- data/lib/timekit/findtime/filtercollections/client.rb +1 -0
- data/lib/timekit/request.rb +2 -1
- data/lib/timekit/user.rb +1 -0
- data/lib/timekit/user/client.rb +1 -0
- data/lib/timekit/version.rb +2 -1
- data/lib/timekit/widget.rb +1 -0
- data/lib/timekit/widget/client.rb +1 -0
- data/timekit.gemspec +4 -3
- metadata +5 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: adacb23f2e944fce92cbd0f0e6a4a11f9dd76f5e
|
4
|
+
data.tar.gz: 3ddc3a70a9f030c443865c0eafb472a7c1b8e0de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18b055f4976b428266267bbc1847af6cb892b66fe0d7b1aa3d40ccb46819fb93b4848a9a01537dc6e2b6e730848c1798d1187e7057631f21851cef44ac409bcf
|
7
|
+
data.tar.gz: 4b5cd189e68793806ae4746f59fe874f70da249d4e1906305a44e2ef85f223e65d3441cbdc7aea52bc5566bde68079d5a632907c3b6f12838944373103ba3c7a
|
data/lib/base.rb
ADDED
@@ -0,0 +1,146 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rest-client'
|
4
|
+
require 'active_model'
|
5
|
+
# require 'activemodel/serializers/xml'
|
6
|
+
# TODO: include strong_parameters?
|
7
|
+
|
8
|
+
module ActiveRest
|
9
|
+
class Base
|
10
|
+
include ActiveModel::AttributeMethods
|
11
|
+
include ActiveModel::Serialization
|
12
|
+
include ActiveModel::Serializers::JSON
|
13
|
+
# include ActiveModel::Serializers::Xml
|
14
|
+
|
15
|
+
def attributes=(hash)
|
16
|
+
hash.each do |key, value|
|
17
|
+
send("#{key}=", value)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def attributes
|
22
|
+
@attributes.to_hash
|
23
|
+
end
|
24
|
+
|
25
|
+
# def attributes
|
26
|
+
# {'name' => nil}
|
27
|
+
# end
|
28
|
+
|
29
|
+
def self.api(configurations)
|
30
|
+
configurations.each do |key, value|
|
31
|
+
define_singleton_method("api_#{key}") { nil }
|
32
|
+
singleton_class.class_eval do
|
33
|
+
remove_method("api_#{key}") if method_defined?("api_#{key}")
|
34
|
+
define_method("api_#{key}") { value }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# method GET
|
40
|
+
def self.all
|
41
|
+
puts name.to_s + ' .all'
|
42
|
+
# get
|
43
|
+
end
|
44
|
+
|
45
|
+
# method GET
|
46
|
+
def self.find(id)
|
47
|
+
puts name.to_s + ' .find ' + id
|
48
|
+
# get("/#{id}")
|
49
|
+
end
|
50
|
+
|
51
|
+
# method POST
|
52
|
+
def self.create(attrs = {})
|
53
|
+
puts name.to_s + ' .create ' + attrs.inspect
|
54
|
+
end
|
55
|
+
|
56
|
+
# serialize the attrs and PUT
|
57
|
+
# method PUT
|
58
|
+
def update(attrs = {})
|
59
|
+
puts name.to_s + ' .update ' + attrs.inspect
|
60
|
+
resp = self.class.request(:put, "/#{id}", attrs)
|
61
|
+
assign_attributes(resp)
|
62
|
+
end
|
63
|
+
|
64
|
+
# serialize the current state of all attributes
|
65
|
+
# method PUT
|
66
|
+
# def save
|
67
|
+
# puts name.to_s + ' .save'
|
68
|
+
# update(serialize)
|
69
|
+
# end
|
70
|
+
|
71
|
+
# method DELETE
|
72
|
+
# def destroy
|
73
|
+
# puts name.to_s + ' .destroy'
|
74
|
+
# resp = self.class.delete("/#{id}")
|
75
|
+
# end
|
76
|
+
|
77
|
+
#
|
78
|
+
# Wrapper method for the request methods of the same names
|
79
|
+
#
|
80
|
+
def self.get(tokens = '')
|
81
|
+
resp = request(:get, tokens)
|
82
|
+
return initialize_objects(resp) if resp.is_a?(Array)
|
83
|
+
return initialize_object(resp) if resp.is_a?(Hash)
|
84
|
+
raise 'Unknown response format'
|
85
|
+
end
|
86
|
+
|
87
|
+
def self.post(tokens = '', attrs)
|
88
|
+
resp = request(:post, tokens, attrs)
|
89
|
+
initialize_object(resp)
|
90
|
+
end
|
91
|
+
|
92
|
+
def self.put(tokens, attrs)
|
93
|
+
request(:put, tokens, attrs)
|
94
|
+
end
|
95
|
+
|
96
|
+
def self.delete(tokens = '')
|
97
|
+
request(:delete, tokens)
|
98
|
+
end
|
99
|
+
|
100
|
+
# def self.initialize_object(attrs)
|
101
|
+
# obj = new(attrs)
|
102
|
+
# obj.assign_attributes(attrs)
|
103
|
+
# end
|
104
|
+
#
|
105
|
+
# def self.initialize_objects(attrs_arr)
|
106
|
+
# attrs_arr.map { |attrs| initialize_object(attrs) }
|
107
|
+
# end
|
108
|
+
|
109
|
+
def self.request(verb, tokens = '', params = nil)
|
110
|
+
# puts "ApiClient::request #{verb},"\
|
111
|
+
# " #{BASE_URL}#{path}, #{params}, #{headers}"
|
112
|
+
path = method_defined?(:api_path) ? api_path : ''
|
113
|
+
|
114
|
+
response = RestClient::Request.execute(
|
115
|
+
method: verb,
|
116
|
+
url: api_url + path + tokens,
|
117
|
+
payload: params ? serialize(params) : to_json,
|
118
|
+
headers: {
|
119
|
+
content_type: 'application/json',
|
120
|
+
accept: 'application/json'
|
121
|
+
}.merge!(api_headers)
|
122
|
+
)
|
123
|
+
|
124
|
+
deserialize(response)
|
125
|
+
end
|
126
|
+
|
127
|
+
def assign_attributes(_values, _options = {})
|
128
|
+
send("#{k}=", v)
|
129
|
+
end
|
130
|
+
|
131
|
+
def serialize(payload)
|
132
|
+
# this may not always be json
|
133
|
+
# payload.to_xml
|
134
|
+
payload.to_json
|
135
|
+
end
|
136
|
+
|
137
|
+
def deserialize(payload)
|
138
|
+
# this may not always be json
|
139
|
+
# from_xml(payload)
|
140
|
+
from_json(payload)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
require_relative './active_rest/api_model'
|
145
|
+
require_relative './active_rest/concrete_example_model'
|
146
|
+
require_relative './active_rest/other_model'
|
data/lib/timekit.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require_relative './timekit/config'
|
3
4
|
require_relative './timekit/client'
|
4
5
|
require_relative './timekit/authorization'
|
@@ -27,9 +28,11 @@ module Timekit
|
|
27
28
|
|
28
29
|
email = configurations[:email]
|
29
30
|
token = configurations[:api_token]
|
31
|
+
return unless email && token
|
32
|
+
|
30
33
|
config[:credentials] = Timekit::Authorization.new(
|
31
34
|
email, token
|
32
|
-
)
|
35
|
+
)
|
33
36
|
end
|
34
37
|
|
35
38
|
def self.calendar_client
|
data/lib/timekit/app.rb
CHANGED
data/lib/timekit/app/client.rb
CHANGED
data/lib/timekit/booking.rb
CHANGED
data/lib/timekit/calendar.rb
CHANGED
data/lib/timekit/client.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'base64'
|
3
4
|
|
4
5
|
module Timekit
|
@@ -16,7 +17,7 @@ module Timekit
|
|
16
17
|
#
|
17
18
|
# Wrapper method for the timekit request methods of the same names
|
18
19
|
#
|
19
|
-
[
|
20
|
+
%i[get put post delete].each do |verb|
|
20
21
|
define_method(verb) do |path, params = {}|
|
21
22
|
# puts "Timekit::Client::#{verb} => #{path}#{token}"
|
22
23
|
headers = {
|
data/lib/timekit/config.rb
CHANGED
data/lib/timekit/credential.rb
CHANGED
data/lib/timekit/event.rb
CHANGED
data/lib/timekit/event/client.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Timekit
|
3
4
|
class Event
|
4
5
|
# Client class for the event resource
|
@@ -42,13 +43,13 @@ module Timekit
|
|
42
43
|
|
43
44
|
params = set_optional_params(
|
44
45
|
binding,
|
45
|
-
[
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
46
|
+
%i[
|
47
|
+
participants
|
48
|
+
invite
|
49
|
+
description
|
50
|
+
my_rsvp
|
51
|
+
sync_provider
|
52
|
+
all_day
|
52
53
|
],
|
53
54
|
params
|
54
55
|
)
|
@@ -71,11 +72,11 @@ module Timekit
|
|
71
72
|
|
72
73
|
params = set_optional_params(
|
73
74
|
binding,
|
74
|
-
[
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
75
|
+
%i[
|
76
|
+
what
|
77
|
+
where
|
78
|
+
participants
|
79
|
+
all_day
|
79
80
|
],
|
80
81
|
params
|
81
82
|
)
|
@@ -1,7 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Timekit
|
3
4
|
class Filtercollection
|
4
|
-
DAYS = %w
|
5
|
+
DAYS = %w[
|
5
6
|
Monday
|
6
7
|
Tuesday
|
7
8
|
Wednesday
|
@@ -9,7 +10,7 @@ module Timekit
|
|
9
10
|
Friday
|
10
11
|
Saturday
|
11
12
|
Sunday
|
12
|
-
|
13
|
+
].freeze
|
13
14
|
|
14
15
|
def initialize
|
15
16
|
@and_conditions = []
|
data/lib/timekit/findtime.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Timekit
|
3
4
|
class Findtime
|
4
5
|
# Client class for the findtime resource
|
@@ -28,15 +29,15 @@ module Timekit
|
|
28
29
|
!value.nil?
|
29
30
|
end
|
30
31
|
|
31
|
-
|
32
|
-
'
|
33
|
-
|
32
|
+
unless params[:emails] || params[:user_ids] || params[:calendar_ids]
|
33
|
+
raise 'Entity id required to find time'\
|
34
|
+
' (email,user id,calendar id)'
|
35
|
+
end
|
34
36
|
|
35
37
|
post(API_PATH, params)
|
36
38
|
end
|
37
39
|
|
38
|
-
def bulk_query(queries)
|
39
|
-
end
|
40
|
+
def bulk_query(queries); end
|
40
41
|
end
|
41
42
|
end
|
42
43
|
end
|
data/lib/timekit/request.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'singleton'
|
3
4
|
require 'rest-client'
|
4
5
|
|
@@ -9,7 +10,7 @@ module Timekit
|
|
9
10
|
|
10
11
|
BASE_URL = 'https://api.timekit.io/v2'
|
11
12
|
|
12
|
-
[
|
13
|
+
%i[get put post delete].each do |verb|
|
13
14
|
define_method(verb) do |path, params, headers|
|
14
15
|
request __method__, path, params, headers
|
15
16
|
end
|
data/lib/timekit/user.rb
CHANGED
data/lib/timekit/user/client.rb
CHANGED
data/lib/timekit/version.rb
CHANGED
data/lib/timekit/widget.rb
CHANGED
data/timekit.gemspec
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
lib = File.expand_path('../lib', __FILE__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
5
|
require 'timekit/version'
|
@@ -14,10 +15,10 @@ Gem::Specification.new do |s|
|
|
14
15
|
s.files = ['lib/timekit.rb']
|
15
16
|
s.homepage = 'https://github.com/mgauthier/timekit'
|
16
17
|
s.license = 'MIT'
|
17
|
-
s.require_paths = %w
|
18
|
-
s.files = %w
|
18
|
+
s.require_paths = %w[lib]
|
19
|
+
s.files = %w[
|
19
20
|
CHANGELOG.md CONTRIBUTING.md LICENSE.md README.md timekit.gemspec
|
20
|
-
|
21
|
+
] + Dir['lib/**/*.rb']
|
21
22
|
s.version = Timekit::Version
|
22
23
|
s.required_ruby_version = '~> 2.1'
|
23
24
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: timekit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Gauthier
|
@@ -34,6 +34,10 @@ files:
|
|
34
34
|
- CONTRIBUTING.md
|
35
35
|
- LICENSE.md
|
36
36
|
- README.md
|
37
|
+
- lib/active_rest/api_model.rb
|
38
|
+
- lib/active_rest/concrete_example_model.rb
|
39
|
+
- lib/active_rest/other_model.rb
|
40
|
+
- lib/base.rb
|
37
41
|
- lib/timekit.rb
|
38
42
|
- lib/timekit/app.rb
|
39
43
|
- lib/timekit/app/client.rb
|