inforouter 0.2.9 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MWY5ZDQ0NmQxMjZkYmQyZDRjZDhhODY5ZTZkYWFiMmE5OTA1MDJhZQ==
4
+ NTJiZDY5MGU4ZTIyNzBlZGQ0NzM2Zjc0ZTQwMDA0MWVjNjMxYzg4Mg==
5
5
  data.tar.gz: !binary |-
6
- ZTkzNDY2Njk4MjQ1Y2M2YWExNTA4NDgxNDU1ZTQ2NDQ5OGUxODdjMA==
6
+ OTgyZDM5ZTc4YmM4ZmU0MGM4MzUzNzgyZjczNzA4YzMwMzhhNGI1OQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MzI1OWY3YTkwYTRlN2FiOTQ2YzNmZTEwYjgyMzU0MTkwOTk0MDgxYTYyMmI5
10
- NWEyZTE0ZGEwMGU3ODJmNDYxYjI2Mzc1NWFmNWQ3NmU1MzQ3ZThhODY5MTQ0
11
- NjZhZGE0OGZkZDRkMWIwYzA2ZmZiMDJkODlhYWEzNzRkNWQ3MTc=
9
+ OWMwNTFmZjdhMDA4OTM4ZDMyOGMyYmY5MWNkYTFmYmQ2MDc0Y2Q4ZGY1NzUz
10
+ MTIzMDI4OTkzNWIxZWU2MGIzMzc2NTJiZDc5MGEwZmNhNzg3NGI5NTMzMzli
11
+ YmVlYzc0MDI1NzhjNTI1MTIyZTI3Y2FkZWY3ZGJhODQyNzNjMzQ=
12
12
  data.tar.gz: !binary |-
13
- ODI5YTdmMzc0NTI0ZTA1N2EwOTVjYzBiZDc4YWRhNjQyYzJiYjVkNzYxYzJl
14
- ZjhiY2QwM2ZmZjNjNDFiN2EzZmYyZDI1NjBkZDRmOTcwMDllMjYyOTY2MjIx
15
- NGQxODY3NjdjNDc4OGRhNTFiZGFjYTc1M2U3OGQxOWM1MGFiNGM=
13
+ YjNlYWZmYmQ4OGM4OTBjYTJlNDQ3NmNjODA1N2M0MmJmNzE3ZDE0MzYyMmVm
14
+ NWI3NWI0OGMyNjVhZTA2MDg1ODhiYzUyOWJhNWNiZmZhNDUxZWZhNWJjMTNh
15
+ MTRiZTYzMDMzY2U5MzFhMzc0NDQxYjI1NWZjNmNlZDQ5YjU3YjU=
@@ -28,11 +28,6 @@ module Inforouter #:nodoc:
28
28
  # Folder documents. Array of <tt>Inforouter::Document</tt>s.
29
29
  attr_accessor :documents
30
30
 
31
- def initialize(params = {})
32
- params = { property_sets: [] }.merge(params)
33
- super params
34
- end
35
-
36
31
  # Find by path.
37
32
  def self.find(options = {})
38
33
  folder = Folder.new(options)
@@ -115,6 +110,8 @@ module Inforouter #:nodoc:
115
110
  result[:@success] == 'true'
116
111
  end
117
112
 
113
+ # Property Sets.
114
+
118
115
  # @return [Boolean]
119
116
  def add_property_sets
120
117
  request_params = {
@@ -126,6 +123,23 @@ module Inforouter #:nodoc:
126
123
  result[:@success] == 'true'
127
124
  end
128
125
 
126
+ # @return [Boolean]
127
+ def delete_property_set!(name)
128
+ # Select property set by name.
129
+ property_set = @property_sets.select { |p| p.name == name }.first
130
+ return false unless property_set
131
+ request_params = {
132
+ :path => path,
133
+ 'xmlpset' => property_set.delete_xml
134
+ }
135
+ response = Inforouter.client.request :delete_property_set_row, request_params
136
+ result = Inforouter::Responses::DeletePropertySetRow.parse response
137
+ if result[:@success] == 'true'
138
+ @property_sets.reject! { |p| p.name == name }
139
+ end
140
+ result[:@success] == 'true'
141
+ end
142
+
129
143
  # @return [Boolean]
130
144
  def update_property_sets
131
145
  request_params = {
@@ -133,10 +147,12 @@ module Inforouter #:nodoc:
133
147
  'xmlpset' => PropertySet.to_xml(property_sets)
134
148
  }
135
149
  response = Inforouter.client.request :update_property_set_row, request_params
136
- result = Inforouter::Responses::UpdatePropertySetRow response
150
+ result = Inforouter::Responses::UpdatePropertySetRow.parse response
137
151
  result[:@success] == 'true'
138
152
  end
139
153
 
154
+ # Rules.
155
+
140
156
  # @return [Boolean]
141
157
  def update_rules(options = {})
142
158
  options = { apply_to_tree: false }.merge(options)
@@ -159,7 +175,7 @@ module Inforouter #:nodoc:
159
175
 
160
176
  # @return [Hash]
161
177
  def folder_params(options = {})
162
- options = { with_property_sets: false }.merge(options)
178
+ options = { with_property_sets: true }.merge(options)
163
179
  {
164
180
  :path => path,
165
181
  :with_rules => 0,
@@ -1,11 +1,35 @@
1
1
  module Inforouter #:nodoc:
2
2
  class PropertyRow < Record
3
3
  # Property row index.
4
- attr_accessor :index
4
+ attr_accessor :row_nbr
5
5
 
6
+ alias :row_number :row_nbr
7
+
8
+ # @params params [Hash]
6
9
  def initialize(params = {})
7
- params = { index: 0 }.merge(params)
8
- super params
10
+ # Declare instance variables from params hash.
11
+ params.each do |k, v|
12
+ # Remove leading at.
13
+ k = k.to_s.sub(/^@/, '')
14
+ instance_variable_set("@#{k}", v)
15
+ eigenclass = class << self; self; end
16
+ eigenclass.class_eval do
17
+ attr_accessor k
18
+ end
19
+ end
20
+ end
21
+
22
+ # @param xml [Nokogiri::XML::Builder]
23
+ #
24
+ # @return [Nokogiri::XML::Builder::NodeBuilder]
25
+ def to_xml(xml)
26
+ fields = {}
27
+ instance_variables.each do |ivar|
28
+ name = ivar.to_s.sub(/^@/, '')
29
+ name == 'row_nbr' ? name = 'RowNbr' : name.upcase!
30
+ fields[name] = instance_variable_get(ivar)
31
+ end
32
+ xml.propertyrow fields unless fields.empty?
9
33
  end
10
34
  end
11
35
  end
@@ -30,5 +30,26 @@ module Inforouter #:nodoc:
30
30
  end
31
31
  builder.doc.root.to_xml
32
32
  end
33
+
34
+ # <Propertysets>
35
+ # <propertyset Name="LETTER">
36
+ # <propertyrow RowNbr="1"/>
37
+ # <propertyrow RowNbr="3"/>
38
+ # </propertyset>
39
+ # </Propertysets>
40
+ #
41
+ # @return [String]
42
+ def delete_xml
43
+ builder = Nokogiri::XML::Builder.new do |xml|
44
+ xml.Propertysets do
45
+ xml.propertyset(Name: @name) do
46
+ @rows.each do |row|
47
+ xml.propertyrow(RowNbr: row.row_number)
48
+ end
49
+ end
50
+ end
51
+ end
52
+ builder.doc.root.to_xml
53
+ end
33
54
  end
34
55
  end
@@ -3,6 +3,7 @@ require 'inforouter/responses/generic'
3
3
  require 'inforouter/responses/access_list'
4
4
  require 'inforouter/responses/create_folder'
5
5
  require 'inforouter/responses/delete_folder'
6
+ require 'inforouter/responses/delete_property_set_row'
6
7
  require 'inforouter/responses/document'
7
8
  require 'inforouter/responses/document_exists'
8
9
  require 'inforouter/responses/documents'
@@ -0,0 +1,10 @@
1
+ module Inforouter #:nodoc:
2
+ module Responses #:nodoc:
3
+ # Response to an infoRouter Delete Property Set Row API call.
4
+ #
5
+ # See http://www.inforouter.com/web-services-80/default.aspx?op=DeletePropertySetRow
6
+ class DeletePropertySetRow < Generic
7
+ response_key :delete_property_set_row
8
+ end
9
+ end
10
+ end
@@ -19,6 +19,7 @@ module Inforouter #:nodoc:
19
19
  return nil if data[:folder].nil?
20
20
  folder = data[:folder]
21
21
  Inforouter::Folder.new(
22
+ property_sets: parse_property_sets(folder[:propertysets]),
22
23
  id: folder[:@folder_id].to_i,
23
24
  parent_id: folder[:@parent_id].to_i,
24
25
  name: folder[:@name].strip,
@@ -29,6 +30,26 @@ module Inforouter #:nodoc:
29
30
  domain_id: folder[:@domain_id].to_i
30
31
  )
31
32
  end
33
+
34
+ private
35
+
36
+ def parse_property_sets(propertysets)
37
+ return [] if propertysets.nil?
38
+ property_sets = []
39
+ propertysets = [propertysets] if propertysets.is_a?(Hash)
40
+ propertysets.each do |propertyset|
41
+ propertyrows = propertyset[:propertyset][:propertyrow]
42
+ next if propertyrows.nil?
43
+ propertyrows = [propertyrows] if propertyrows.is_a?(Hash)
44
+ # Create a property set and add rows.
45
+ property_set = Inforouter::PropertySet.new name: propertyset[:propertyset][:@name]
46
+ propertyrows.each do |propertyrow|
47
+ property_set.rows << Inforouter::PropertyRow.new(propertyrow)
48
+ end
49
+ property_sets << property_set
50
+ end
51
+ property_sets
52
+ end
32
53
  end
33
54
  end
34
55
  end
@@ -1,8 +1,8 @@
1
1
  module Inforouter
2
2
  class Version
3
3
  MAJOR = 0
4
- MINOR = 2
5
- PATCH = 9
4
+ MINOR = 3
5
+ PATCH = 0
6
6
  PRE = nil
7
7
 
8
8
  class << self
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inforouter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.9
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Fenton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-16 00:00:00.000000000 Z
11
+ date: 2015-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -164,6 +164,7 @@ files:
164
164
  - lib/inforouter/responses/base.rb
165
165
  - lib/inforouter/responses/create_folder.rb
166
166
  - lib/inforouter/responses/delete_folder.rb
167
+ - lib/inforouter/responses/delete_property_set_row.rb
167
168
  - lib/inforouter/responses/document.rb
168
169
  - lib/inforouter/responses/document_exists.rb
169
170
  - lib/inforouter/responses/documents.rb