Class: WebmaniabrNfeRuby::Models::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/models/request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Request

Returns a new instance of Request.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/models/request.rb', line 8

def initialize(options = {})
  @id               = options[:id]
  @url_notification = options[:url_notification]
  @operation        = options[:operation]
  @operation_nature = options[:operation_nature]
  @model            = options[:model]
  @emission         = options[:emission]
  @goal             = options[:goal]
  @environment      = options[:environment]
  @client           = options[:client]
  @products         = options[:products]
  @order            = options[:order]
  @transport        = options[:transport]
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



4
5
6
# File 'lib/models/request.rb', line 4

def client
  @client
end

#emissionObject

Returns the value of attribute emission.



4
5
6
# File 'lib/models/request.rb', line 4

def emission
  @emission
end

#environmentObject

Returns the value of attribute environment.



4
5
6
# File 'lib/models/request.rb', line 4

def environment
  @environment
end

#goalObject

Returns the value of attribute goal.



4
5
6
# File 'lib/models/request.rb', line 4

def goal
  @goal
end

#idObject

Returns the value of attribute id.



4
5
6
# File 'lib/models/request.rb', line 4

def id
  @id
end

#modelObject

Returns the value of attribute model.



4
5
6
# File 'lib/models/request.rb', line 4

def model
  @model
end

#operationObject

Returns the value of attribute operation.



4
5
6
# File 'lib/models/request.rb', line 4

def operation
  @operation
end

#operation_natureObject

Returns the value of attribute operation_nature.



4
5
6
# File 'lib/models/request.rb', line 4

def operation_nature
  @operation_nature
end

#orderObject

Returns the value of attribute order.



4
5
6
# File 'lib/models/request.rb', line 4

def order
  @order
end

#productsObject

Returns the value of attribute products.



4
5
6
# File 'lib/models/request.rb', line 4

def products
  @products
end

#transportObject

Returns the value of attribute transport.



4
5
6
# File 'lib/models/request.rb', line 4

def transport
  @transport
end

#url_notificationObject

Returns the value of attribute url_notification.



4
5
6
# File 'lib/models/request.rb', line 4

def url_notification
  @url_notification
end

Instance Method Details

#to_hashObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/models/request.rb', line 23

def to_hash
  products = []

  if @products.class == Array
    @products.each do |product|
      products.push product.to_hash
    end
  end

  {
    ID: @id,
    url_notificacao: @url_notification,
    operacao: @operation,
    natureza_operacao: @operation_nature,
    modelo: @model,
    emissao: @emission,
    finalidade: @goal,
    ambiente: @environment,
    cliente: @client.to_hash,
    produtos: products,
    pedido: @order.to_hash,
    transporte: @transport ? @transport.to_hash : nil
  }
end