ragoon 0.1.2 → 0.2.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/ragoon.rb +1 -0
- data/lib/ragoon/client.rb +4 -0
- data/lib/ragoon/services.rb +9 -1
- data/lib/ragoon/services/notification.rb +85 -0
- data/lib/ragoon/services/schedule.rb +1 -5
- data/lib/ragoon/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12fc8358cceea9d28479abb355d9e6a3d9afdec3
|
4
|
+
data.tar.gz: e8f40376e28e84674a9357375cbf609e51f1a4d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a150442661ae09d84b356ba2ccb028009f6c8a19cfc9996f05183eefb539164493ec02a04111272c5a7dedd8f1b2a06265e0e46711c0f9179d882553ecc30889
|
7
|
+
data.tar.gz: 3454e259bd635c2b3502be38c88d2c3d3a3f0b84333e0b38e3eb9e74c3c4161bbb916ad5c5985471ee49eaf9b8f559a4c2ba47ee7c9054ed0495af53d847ab0b
|
data/lib/ragoon.rb
CHANGED
data/lib/ragoon/client.rb
CHANGED
data/lib/ragoon/services.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
class Ragoon::Services
|
2
2
|
SERVICE_LOCATIONS = {
|
3
|
-
schedule:
|
3
|
+
schedule: '/cbpapi/schedule/api?',
|
4
|
+
notification: '/cbpapi/notification/api?',
|
4
5
|
}.freeze
|
5
6
|
|
6
7
|
attr_reader :client, :action_type
|
@@ -14,4 +15,11 @@ class Ragoon::Services
|
|
14
15
|
endpoint = URI(Ragoon.garoon_endpoint)
|
15
16
|
"#{endpoint.scheme}://#{endpoint.host}#{endpoint.path}#{SERVICE_LOCATIONS[action_type]}"
|
16
17
|
end
|
18
|
+
|
19
|
+
def self.start_and_end(date = Date.today)
|
20
|
+
{
|
21
|
+
start: Time.local(date.year, date.month, date.day, 0).utc,
|
22
|
+
end: Time.local(date.year, date.month, date.day + 1, 0).utc,
|
23
|
+
}
|
24
|
+
end
|
17
25
|
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
class Ragoon::Services::Notification < Ragoon::Services
|
2
|
+
RETRIEVE_OPTIONS = {
|
3
|
+
date: Date.today,
|
4
|
+
module_ids: %w[grn.schedule grn.workflow],
|
5
|
+
}.freeze
|
6
|
+
|
7
|
+
def retrieve(options = {})
|
8
|
+
options = RETRIEVE_OPTIONS.dup.merge(options)
|
9
|
+
results = options[:module_ids].each_with_object({}) do |module_id, result|
|
10
|
+
result[module_id] = notification_get_notification_versions(module_id, options[:date])
|
11
|
+
client.reset
|
12
|
+
end
|
13
|
+
|
14
|
+
items = results.each_with_object([]) do |(module_id, notifications), result|
|
15
|
+
notifications.xpath('//notification_item').each do |notification|
|
16
|
+
result.push(
|
17
|
+
{
|
18
|
+
module_id: module_id,
|
19
|
+
item: notification.xpath('notification_id').first[:item]
|
20
|
+
}
|
21
|
+
)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
notifications = notification_get_notifications_by_id(items)
|
26
|
+
keys = notifications.xpath('//notification').first.attributes.keys.map(&:to_sym)
|
27
|
+
|
28
|
+
notifications.xpath('//notification').each_with_object([]) do |notification, result|
|
29
|
+
result.push(
|
30
|
+
keys.each_with_object({}) { |key, hash| hash[key] = notification[key] }
|
31
|
+
)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def notification_get_notification_versions(module_id, date)
|
36
|
+
action_name = 'NotificationGetNotificationVersions'
|
37
|
+
body_node = Ragoon::XML.create_node(action_name)
|
38
|
+
target_date = Ragoon::Services.start_and_end(date)
|
39
|
+
|
40
|
+
parameter_node = Ragoon::XML.create_node(
|
41
|
+
'parameters',
|
42
|
+
start: target_date[:start].strftime('%FT%T'),
|
43
|
+
end: target_date[:end].strftime('%FT%T'),
|
44
|
+
module_id: module_id,
|
45
|
+
)
|
46
|
+
|
47
|
+
body_node.add_child(parameter_node)
|
48
|
+
|
49
|
+
client.request(action_name, body_node)
|
50
|
+
client.result_set
|
51
|
+
end
|
52
|
+
|
53
|
+
def notification_get_notifications_by_id(notification_items)
|
54
|
+
action_name = 'NotificationGetNotificationsById'
|
55
|
+
body_node = Ragoon::XML.create_node(action_name)
|
56
|
+
today = Ragoon::Services.start_and_end
|
57
|
+
|
58
|
+
parameter_node = Ragoon::XML.create_node('parameters')
|
59
|
+
|
60
|
+
notification_items.each do |notification_item|
|
61
|
+
parameter_node.add_child(
|
62
|
+
Ragoon::XML.create_node(
|
63
|
+
'notification_id',
|
64
|
+
module_id: notification_item[:module_id],
|
65
|
+
item: notification_item[:item],
|
66
|
+
)
|
67
|
+
)
|
68
|
+
end
|
69
|
+
|
70
|
+
body_node.add_child(parameter_node)
|
71
|
+
|
72
|
+
client.request(action_name, body_node)
|
73
|
+
client.result_set
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
def default_options(action_name)
|
78
|
+
case action_name
|
79
|
+
when 'ScheduleGetEvents'
|
80
|
+
Ragoon::Services.start_and_end
|
81
|
+
else
|
82
|
+
{}
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -47,11 +47,7 @@ class Ragoon::Services::Schedule < Ragoon::Services
|
|
47
47
|
def default_options(action_name)
|
48
48
|
case action_name
|
49
49
|
when 'ScheduleGetEvents'
|
50
|
-
|
51
|
-
{
|
52
|
-
start: Time.local(today.year, today.month, today.day, 0).utc,
|
53
|
-
end: Time.local(today.year, today.month, today.day + 1, 0).utc,
|
54
|
-
}
|
50
|
+
Ragoon::Services.start_and_end
|
55
51
|
else
|
56
52
|
{}
|
57
53
|
end
|
data/lib/ragoon/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ragoon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SHIOYA, Hiromu
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -99,6 +99,7 @@ files:
|
|
99
99
|
- lib/ragoon.rb
|
100
100
|
- lib/ragoon/client.rb
|
101
101
|
- lib/ragoon/services.rb
|
102
|
+
- lib/ragoon/services/notification.rb
|
102
103
|
- lib/ragoon/services/schedule.rb
|
103
104
|
- lib/ragoon/version.rb
|
104
105
|
- lib/ragoon/xml.rb
|
@@ -123,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
124
|
version: '0'
|
124
125
|
requirements: []
|
125
126
|
rubyforge_project:
|
126
|
-
rubygems_version: 2.4.
|
127
|
+
rubygems_version: 2.4.5.1
|
127
128
|
signing_key:
|
128
129
|
specification_version: 4
|
129
130
|
summary: Ragoon is a simple Garoon 3 API client.
|