glossyapp 0.1.1 → 0.1.2

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: 9024b71eaebac9a9af5bc96065ff4aa095889a9c
4
- data.tar.gz: 12a8e2b28966f02a4e46c82d1a706f1c8633ea32
3
+ metadata.gz: 83d1b292b327a89672de3093508d8814100c92ec
4
+ data.tar.gz: 8d0261d67fffc6bb1ae1a16a372401dedc7e2248
5
5
  SHA512:
6
- metadata.gz: 3fa59df686edd02a1be223d2bf1503ea7e59303e37e42302505bbd965f5ed21bf41140301b6bd4c48f214e74cce2030a292c47f5512adaad5823a931c08bfa43
7
- data.tar.gz: a4052f063e3e82da5a2a424bda075b14c9f81c03a34b5e8d15c85db97d3a40470c90d44984a891a0f60f2564bf4fe0161316b0fa9a70737d456fe71e9b874a29
6
+ metadata.gz: 28343382cf62028e639727a9344f37c3aff7e33e0090666c3b9c59d38b0d87913037fc58252f11b514c4103eb15fb9e788178398c71e82fd2db760c77d5de74a
7
+ data.tar.gz: 701046567fc15f49b82845d113665517d96263597219176372b091e30680e7ee8a2d926587d84b614472516d93dfd2bea37d323069a7d57281922442aed541f0
@@ -1,11 +1,39 @@
1
1
  module GlossyApp
2
2
 
3
3
  class Session
4
+
5
+ def create_page_element(document_id, page_id, x, y, width, height, type, data, title = nil)
6
+ data = {
7
+ 'page_element' => {
8
+ 'page_id' => page_id,
9
+ 'type' => type,
10
+ 'title' => title,
11
+ 'x' => x,
12
+ 'y' => y,
13
+ 'width' => width,
14
+ 'height' => height
15
+ }.merge(data)
16
+ }
17
+
18
+ response = @glossy_api.post("/documents/#{document_id}/pages/#{page_id}/page_elements", data.to_json, {"Content-Type" => "application/json"})
19
+ if [200, 201].include?(response.status)
20
+ json = JSON.parse(response.body)
21
+ return json['id']
22
+ else
23
+ raise "Invalid response: #{response.inspect}\n#{response.body}"
24
+ end
25
+ end
4
26
 
5
- def bla
6
- puts "bla"
27
+ def delete_page_element(document_id, page_id, page_element_id)
28
+ response = @glossy_api.delete "/documents/#{document_id}/pages/#{page_id}/page_elements/#{page_element_id}"
29
+ if [200].include?(response.status)
30
+ return true
31
+ else
32
+ raise "Invalid response: #{response.inspect}\n#{response.body}"
33
+ end
7
34
  end
8
35
 
36
+
9
37
  end
10
38
 
11
39
  end
@@ -11,6 +11,20 @@ module GlossyApp
11
11
  end
12
12
  end
13
13
 
14
+ def page_id_for_page_position(document_id, position)
15
+ response = @glossy_api.get "/documents/#{document_id}/pages?positions=#{position}"
16
+ if [200].include?(response.status)
17
+ json = JSON.parse(response.body)
18
+ if json['pages'].is_a?(Array) and json['pages'].size > 0
19
+ return json['pages'].first['id']
20
+ else
21
+ return nil
22
+ end
23
+ else
24
+ return nil
25
+ end
26
+ end
27
+
14
28
  end
15
29
 
16
30
  end
@@ -1,3 +1,3 @@
1
1
  module GlossyApp
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
data/old_vanga_main.rb CHANGED
@@ -29,50 +29,6 @@ def create_article(article, gallery = nil, asset_file_id = nil)
29
29
  end
30
30
  end
31
31
 
32
- def delete_page_element(page_id, page_element_id)
33
- response = @glossy_api.delete "/documents/#{@options[:document_id]}/pages/#{page_id}/page_elements/#{page_element_id}"
34
- if [200].include?(response.status)
35
- return true
36
- else
37
- raise "Couldn't get pages: #{response.inspect}\n#{response.body}"
38
- end
39
- end
40
-
41
- def create_page_element(page_id, x, y, width, height, type, data, title = nil)
42
- data = {
43
- 'page_element' => {
44
- 'page_id' => page_id,
45
- 'type' => type,
46
- 'title' => title,
47
- 'x' => x,
48
- 'y' => y,
49
- 'width' => width,
50
- 'height' => height
51
- }.merge(data)
52
- }
53
-
54
- response = @glossy_api.post("/documents/#{@options[:document_id]}/pages/#{page_id}/page_elements", data.to_json, {"Content-Type" => "application/json"})
55
- if [200, 201].include?(response.status)
56
- json = JSON.parse(response.body)
57
- # TODO return id of page element
58
- else
59
- raise "Invalid response: #{response.inspect}\n#{response.body}"
60
- end
61
- end
62
-
63
- def page_id_for_page_position(position)
64
- response = @glossy_api.get "/documents/#{@options[:document_id]}/pages?positions=#{position}"
65
- if [200].include?(response.status)
66
- json = JSON.parse(response.body)
67
- if json['pages'].is_a?(Array) and json['pages'].size > 0
68
- return json['pages'].first['id']
69
- else
70
- return nil
71
- end
72
- else
73
- return nil
74
- end
75
- end
76
32
 
77
33
  def toc_section_id_for_section_with_title(title)
78
34
  response = @glossy_api.get "/documents/#{@options[:document_id]}/toc_sections?title=#{CGI.escape(title)}"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glossyapp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philipp Schmid