lib/groupdocs/signature/field.rb in groupdocs-2.2.0 vs lib/groupdocs/signature/field.rb in groupdocs-2.3.0
- old
+ new
@@ -1,286 +1,286 @@
-module GroupDocs
- class Signature::Field < Api::Entity
-
- require 'groupdocs/signature/field/location'
-
- FIELD_TYPES = {
- :signature => 1,
- :single_line => 2,
- :multiline => 3,
- :date => 4,
- :dropdown => 5,
- :checkbox => 6,
- }
-
- #
- # Returns array of predefined lists.
- #
- # @param [Hash] options Hash of options
- # @option options [String] :id Filter by identifier
- # @param [Hash] access Access credentials
- # @option access [String] :client_id
- # @option access [String] :private_key
- # @return [Array<GroupDocs::Signature::Field>]
- #
- def self.get!(options = {}, access = {})
- api = Api::Request.new do |request|
- request[:access] = access
- request[:method] = :GET
- request[:path] = '/signature/{{client_id}}/fields'
- end
- api.add_params(options)
- json = api.execute!
-
- json[:fields].map do |field|
- new(field)
- end
- end
-
- # @attr [String] id
- attr_accessor :id
- # @attr [String] templateId
- attr_accessor :templateId
- # @attr [String] recipientId
- attr_accessor :recipientId
- # @attr [String] signatureFieldId
- attr_accessor :signatureFieldId
- # @attr [String] name
- attr_accessor :name
- # @attr [Integer] graphSizeW
- attr_accessor :graphSizeW
- # @attr [Integer] graphSizeH
- attr_accessor :graphSizeH
- # @attr [String] getDataFrom
- attr_accessor :getDataFrom
- # @attr [String] regularExpression
- attr_accessor :regularExpression
- # @attr [String] fontName
- attr_accessor :fontName
- # @attr [String] fontColor
- attr_accessor :fontColor
- # @attr [Integer] fontSize
- attr_accessor :fontSize
- # @attr [Boolean] fontBold
- attr_accessor :fontBold
- # @attr [Boolean] fontItalic
- attr_accessor :fontItalic
- # @attr [Boolean] fontUnderline
- attr_accessor :fontUnderline
- # @attr [Boolean] isSystem
- attr_accessor :isSystem
- # @attr [Boolean] mandatory
- attr_accessor :mandatory
- # @attr [Integer] fieldType
- attr_accessor :fieldType
- # @attr [Array<String>] acceptableValues
- attr_accessor :acceptableValues
- # @attr [String] defaultValue
- attr_accessor :defaultValue
- # @attr [String] tooltip
- attr_accessor :tooltip
- # @attr [Integer] input
- attr_accessor :input
- # @attr [Integer] order
- attr_accessor :order
- # @attr [String] textRows
- attr_accessor :textRows
- # @attr [String] textColumns
- attr_accessor :textColumns
- # @attr [GroupDocs::Signature::Field::Location] location
- attr_accessor :location
- # @attr [Array<GroupDocs::Signature::Field::Location>] locations
- attr_accessor :locations
-
- # added in realise 1.5.8
- # @attr [Integer] pageWidth
- attr_accessor :pageWidth
- # @attr [Integer] pageHeight
- attr_accessor :pageHeight
- # @attr [String] groupName
- attr_accessor :groupName
- # @attr [String] settings
- attr_accessor :settings
- # @attr [Integer] align
- attr_accessor :align
- # @attr [String] guidanceText
- attr_accessor :guidanceText
-
- # added in realise 2.2.0
- # @attr [Integer] page
- attr_accessor :page
- # @attr [Integer] locationX
- attr_accessor :locationX
- # @attr [Integer] locationY
- attr_accessor :locationY
- # @attr [Integer] locationWidth
- attr_accessor :locationWidth
- # @attr [Integer] locationHeight
- attr_accessor :locationHeight
- # @attr [Integer] forceNewField
- attr_accessor :forceNewField
-
-
- # Human-readable accessors
- alias_accessor :template_id, :templateId
- alias_accessor :recipient_id, :recipientId
- alias_accessor :signature_field_id, :signatureFieldId
- alias_accessor :graph_size_w, :graphSizeW
- alias_accessor :graph_size_w, :graphSizeW
- alias_accessor :graph_size_width, :graphSizeW
- alias_accessor :graph_size_h, :graphSizeH
- alias_accessor :graph_size_height, :graphSizeH
- alias_accessor :get_data_from, :getDataFrom
- alias_accessor :regular_expression, :regularExpression
- alias_accessor :font_name, :fontName
- alias_accessor :font_color, :fontColor
- alias_accessor :font_size, :fontSize
- alias_accessor :font_bold, :fontBold
- alias_accessor :font_italic, :fontItalic
- alias_accessor :font_underline, :fontUnderline
- alias_accessor :is_system, :isSystem
- alias_accessor :default_value, :defaultValue
- alias_accessor :text_rows, :textRows
- alias_accessor :text_columns, :textColumns
- # added in release 1.5.8
- alias_accessor :page_width, :pageWidth
- alias_accessor :page_height, :pageHeight
- alias_accessor :group_name, :groupName
- alias_accessor :guidance_text, :guidanceText
-
-
- #
- # Converts location to GroupDocs::Signature::Field::Location object.
- #
- # @param [GroupDocs::Signature::Field::Location, Hash] location
- #
- def location=(location)
- if location
- @location = (location.is_a?(GroupDocs::Signature::Field::Location) ? location : Signature::Field::Location.new(location))
- locations ? locations << @location : self.locations = [@location]
- end
- end
-
- #
- # Converts each location to GroupDocs::Signature::Field::Location object.
- #
- # @param [Array<GroupDocs::Signature::Field::Location, Hash>] locations
- #
- def locations=(locations)
- if locations
- @locations = locations.map do |location|
- if location.is_a?(GroupDocs::Signature::Field::Location)
- location
- else
- Signature::Field::Location.new(location)
- end
- end
- end
- end
-
- #
- # Saves field type in machine-readable format.
- # @param [Symbol, Integer] type
- #
- def field_type=(type)
- if type.is_a?(Symbol)
- type = FIELD_TYPES[type]
- end
-
- @fieldType = type
- end
- alias_method :type=, :field_type=
-
- #
- # Returns field type in human-readable format.
- # @return [Symbol]
- #
- def field_type
- FIELD_TYPES.invert[@fieldType]
- end
- alias_method :type, :field_type
-
- #
- # Converts array of acceptable values to machine-readable format.
- # @param [Array<String>] values
- #
- def acceptable_values=(values)
- if values.is_a?(Array)
- values = values.join(';')
- end
-
- @acceptableValues = values
- end
-
- #
- # Converts acceptable values to human-readable format.
- # @return [Array<String>]
- #
- def acceptable_values
- @acceptableValues.split(';') if @acceptableValues
- end
-
- #
- # Creates signature field.
- #
- # @example
- # field = GroupDocs::Signature::Field.new
- # field.name = 'Field'
- # field.create!
- #
- # @param [Hash] access Access credentials
- # @option access [String] :client_id
- # @option access [String] :private_key
- #
- def create!(access = {})
- json = Api::Request.new do |request|
- request[:access] = access
- request[:method] = :POST
- request[:path] = '/signature/{{client_id}}/field'
- request[:request_body] = to_hash
- end.execute!
-
- self.id = json[:field][:id]
- end
-
- #
- # Modifies signature field.
- #
- # @example
- # field = GroupDocs::Signature::Field.get!.first
- # field.name = 'Field'
- # field.modify!
- #
- # @param [Hash] access Access credentials
- # @option access [String] :client_id
- # @option access [String] :private_key
- #
- def modify!(access = {})
- Api::Request.new do |request|
- request[:access] = access
- request[:method] = :POST
- request[:path] = "/signature/{{client_id}}/fields/#{id}"
- request[:request_body] = to_hash
- end.execute!
- end
-
- #
- # Deletes signature field.
- #
- # @example Remove all created fields
- # fields = GroupDocs::Signature::Field.get!.select { |field| !field.is_system }
- # fields.each { |field| field.delete! }
- #
- # @param [Hash] access Access credentials
- # @option access [String] :client_id
- # @option access [String] :private_key
- #
- def delete!(access = {})
- Api::Request.new do |request|
- request[:access] = access
- request[:method] = :DELETE
- request[:path] = "/signature/{{client_id}}/fields/#{id}"
- end.execute!
- end
-
- end # Signature::Field
-end # GroupDocs
+module GroupDocs
+ class Signature::Field < Api::Entity
+
+ require 'groupdocs/signature/field/location'
+
+ FIELD_TYPES = {
+ :signature => 1,
+ :single_line => 2,
+ :multiline => 3,
+ :date => 4,
+ :dropdown => 5,
+ :checkbox => 6,
+ }
+
+ #
+ # Returns array of predefined lists.
+ #
+ # @param [Hash] options Hash of options
+ # @option options [String] :id Filter by identifier
+ # @param [Hash] access Access credentials
+ # @option access [String] :client_id
+ # @option access [String] :private_key
+ # @return [Array<GroupDocs::Signature::Field>]
+ #
+ def self.get!(options = {}, access = {})
+ api = Api::Request.new do |request|
+ request[:access] = access
+ request[:method] = :GET
+ request[:path] = '/signature/{{client_id}}/fields'
+ end
+ api.add_params(options)
+ json = api.execute!
+
+ json[:fields].map do |field|
+ new(field)
+ end
+ end
+
+ # @attr [String] id
+ attr_accessor :id
+ # @attr [String] templateId
+ attr_accessor :templateId
+ # @attr [String] recipientId
+ attr_accessor :recipientId
+ # @attr [String] signatureFieldId
+ attr_accessor :signatureFieldId
+ # @attr [String] name
+ attr_accessor :name
+ # @attr [Integer] graphSizeW
+ attr_accessor :graphSizeW
+ # @attr [Integer] graphSizeH
+ attr_accessor :graphSizeH
+ # @attr [String] getDataFrom
+ attr_accessor :getDataFrom
+ # @attr [String] regularExpression
+ attr_accessor :regularExpression
+ # @attr [String] fontName
+ attr_accessor :fontName
+ # @attr [String] fontColor
+ attr_accessor :fontColor
+ # @attr [Integer] fontSize
+ attr_accessor :fontSize
+ # @attr [Boolean] fontBold
+ attr_accessor :fontBold
+ # @attr [Boolean] fontItalic
+ attr_accessor :fontItalic
+ # @attr [Boolean] fontUnderline
+ attr_accessor :fontUnderline
+ # @attr [Boolean] isSystem
+ attr_accessor :isSystem
+ # @attr [Boolean] mandatory
+ attr_accessor :mandatory
+ # @attr [Integer] fieldType
+ attr_accessor :fieldType
+ # @attr [Array<String>] acceptableValues
+ attr_accessor :acceptableValues
+ # @attr [String] defaultValue
+ attr_accessor :defaultValue
+ # @attr [String] tooltip
+ attr_accessor :tooltip
+ # @attr [Integer] input
+ attr_accessor :input
+ # @attr [Integer] order
+ attr_accessor :order
+ # @attr [String] textRows
+ attr_accessor :textRows
+ # @attr [String] textColumns
+ attr_accessor :textColumns
+ # @attr [GroupDocs::Signature::Field::Location] location
+ attr_accessor :location
+ # @attr [Array<GroupDocs::Signature::Field::Location>] locations
+ attr_accessor :locations
+
+ # added in realise 1.5.8
+ # @attr [Integer] pageWidth
+ attr_accessor :pageWidth
+ # @attr [Integer] pageHeight
+ attr_accessor :pageHeight
+ # @attr [String] groupName
+ attr_accessor :groupName
+ # @attr [String] settings
+ attr_accessor :settings
+ # @attr [Integer] align
+ attr_accessor :align
+ # @attr [String] guidanceText
+ attr_accessor :guidanceText
+
+ # added in realise 2.2.0
+ # @attr [Integer] page
+ attr_accessor :page
+ # @attr [Integer] locationX
+ attr_accessor :locationX
+ # @attr [Integer] locationY
+ attr_accessor :locationY
+ # @attr [Integer] locationWidth
+ attr_accessor :locationWidth
+ # @attr [Integer] locationHeight
+ attr_accessor :locationHeight
+ # @attr [Integer] forceNewField
+ attr_accessor :forceNewField
+
+
+ # Human-readable accessors
+ alias_accessor :template_id, :templateId
+ alias_accessor :recipient_id, :recipientId
+ alias_accessor :signature_field_id, :signatureFieldId
+ alias_accessor :graph_size_w, :graphSizeW
+ alias_accessor :graph_size_w, :graphSizeW
+ alias_accessor :graph_size_width, :graphSizeW
+ alias_accessor :graph_size_h, :graphSizeH
+ alias_accessor :graph_size_height, :graphSizeH
+ alias_accessor :get_data_from, :getDataFrom
+ alias_accessor :regular_expression, :regularExpression
+ alias_accessor :font_name, :fontName
+ alias_accessor :font_color, :fontColor
+ alias_accessor :font_size, :fontSize
+ alias_accessor :font_bold, :fontBold
+ alias_accessor :font_italic, :fontItalic
+ alias_accessor :font_underline, :fontUnderline
+ alias_accessor :is_system, :isSystem
+ alias_accessor :default_value, :defaultValue
+ alias_accessor :text_rows, :textRows
+ alias_accessor :text_columns, :textColumns
+ # added in release 1.5.8
+ alias_accessor :page_width, :pageWidth
+ alias_accessor :page_height, :pageHeight
+ alias_accessor :group_name, :groupName
+ alias_accessor :guidance_text, :guidanceText
+
+
+ #
+ # Converts location to GroupDocs::Signature::Field::Location object.
+ #
+ # @param [GroupDocs::Signature::Field::Location, Hash] location
+ #
+ def location=(location)
+ if location
+ @location = (location.is_a?(GroupDocs::Signature::Field::Location) ? location : Signature::Field::Location.new(location))
+ locations ? locations << @location : self.locations = [@location]
+ end
+ end
+
+ #
+ # Converts each location to GroupDocs::Signature::Field::Location object.
+ #
+ # @param [Array<GroupDocs::Signature::Field::Location, Hash>] locations
+ #
+ def locations=(locations)
+ if locations
+ @locations = locations.map do |location|
+ if location.is_a?(GroupDocs::Signature::Field::Location)
+ location
+ else
+ Signature::Field::Location.new(location)
+ end
+ end
+ end
+ end
+
+ #
+ # Saves field type in machine-readable format.
+ # @param [Symbol, Integer] type
+ #
+ def field_type=(type)
+ if type.is_a?(Symbol)
+ type = FIELD_TYPES[type]
+ end
+
+ @fieldType = type
+ end
+ alias_method :type=, :field_type=
+
+ #
+ # Returns field type in human-readable format.
+ # @return [Symbol]
+ #
+ def field_type
+ FIELD_TYPES.invert[@fieldType]
+ end
+ alias_method :type, :field_type
+
+ #
+ # Converts array of acceptable values to machine-readable format.
+ # @param [Array<String>] values
+ #
+ def acceptable_values=(values)
+ if values.is_a?(Array)
+ values = values.join(';')
+ end
+
+ @acceptableValues = values
+ end
+
+ #
+ # Converts acceptable values to human-readable format.
+ # @return [Array<String>]
+ #
+ def acceptable_values
+ @acceptableValues.split(';') if @acceptableValues
+ end
+
+ #
+ # Creates signature field.
+ #
+ # @example
+ # field = GroupDocs::Signature::Field.new
+ # field.name = 'Field'
+ # field.create!
+ #
+ # @param [Hash] access Access credentials
+ # @option access [String] :client_id
+ # @option access [String] :private_key
+ #
+ def create!(access = {})
+ json = Api::Request.new do |request|
+ request[:access] = access
+ request[:method] = :POST
+ request[:path] = '/signature/{{client_id}}/field'
+ request[:request_body] = to_hash
+ end.execute!
+
+ self.id = json[:field][:id]
+ end
+
+ #
+ # Modifies signature field.
+ #
+ # @example
+ # field = GroupDocs::Signature::Field.get!.first
+ # field.name = 'Field'
+ # field.modify!
+ #
+ # @param [Hash] access Access credentials
+ # @option access [String] :client_id
+ # @option access [String] :private_key
+ #
+ def modify!(access = {})
+ Api::Request.new do |request|
+ request[:access] = access
+ request[:method] = :POST
+ request[:path] = "/signature/{{client_id}}/fields/#{id}"
+ request[:request_body] = to_hash
+ end.execute!
+ end
+
+ #
+ # Deletes signature field.
+ #
+ # @example Remove all created fields
+ # fields = GroupDocs::Signature::Field.get!.select { |field| !field.is_system }
+ # fields.each { |field| field.delete! }
+ #
+ # @param [Hash] access Access credentials
+ # @option access [String] :client_id
+ # @option access [String] :private_key
+ #
+ def delete!(access = {})
+ Api::Request.new do |request|
+ request[:access] = access
+ request[:method] = :DELETE
+ request[:path] = "/signature/{{client_id}}/fields/#{id}"
+ end.execute!
+ end
+
+ end # Signature::Field
+end # GroupDocs