netvisor 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/lib/netvisor.rb CHANGED
@@ -7,8 +7,8 @@ module Netvisor
7
7
  attr_accessor :configuration
8
8
  end
9
9
 
10
- def self.new(config)
11
- Netvisor::Base.new(config)
10
+ def self.new
11
+ Netvisor::Base.new
12
12
  end
13
13
 
14
14
  def self.configure
data/lib/netvisor/base.rb CHANGED
@@ -3,19 +3,15 @@ require 'netvisor/request'
3
3
 
4
4
  module Netvisor
5
5
  class Base
6
- def initialize(config)
7
- @config = config
8
- end
9
-
10
6
  def send_invoice(sales_invoice)
11
7
  request(sales_invoice, 'sales_invoice')
12
8
  end
13
9
 
14
10
  def request(data_object, service, method = nil, id = nil)
15
11
  root = Root.new
16
- # root.send(service, data_object)
12
+ root.send("#{service}=", data_object)
17
13
  # validate root
18
- req = Request.new(@config)
14
+ req = Request.new
19
15
 
20
16
  req.send(root.to_xml, service, method, id)
21
17
  end
@@ -4,18 +4,9 @@ module Netvisor
4
4
  class Request
5
5
 
6
6
  def send(xml, service, method = nil, id = nil)
7
- url = build_url(service, method, id)
8
- headers = build_headers(url)
9
- root = Netvisor::Root.parse(File.read("example_salesinvoice.xml"))
10
- xml = root.to_xml
11
- p xml
12
-
13
- new_xml = "<!DOCTYPE salesinvoice SYSTEM \"salesinvoice.dtd\" >" + xml
14
- # tell the parsing to actually load the DTD which it doesn't do by default
15
- # options = Nokogiri::XML::ParseOptions::DEFAULT_XML | Nokogiri::XML::ParseOptions::DTDLOAD
16
- doc = Nokogiri::XML::Document.parse(new_xml)#,nil,nil,options)
7
+ url = self.class.build_url(service, method, id)
8
+ headers = self.class.build_headers(url)
17
9
  xml.gsub!("<?xml version=\"1.0\"?>", '')
18
- p xml
19
10
 
20
11
  res = Faraday.post(url) do |req|
21
12
  req.headers.merge!(headers)
@@ -56,7 +47,7 @@ module Netvisor
56
47
  Netvisor.configuration.customer_key || 'EF1E64BD5D7E0301417B7FE1BF059694',
57
48
  Netvisor.configuration.partner_key || '6F4C9C0DD3C1C263DAC131ED3AF89A7C'
58
49
  ]
59
- p timestamp, arr.join('&')
50
+ p arr.join('&')
60
51
  Digest::SHA2.hexdigest(arr.join('&'))
61
52
  end
62
53
  end
@@ -1,3 +1,3 @@
1
1
  module Netvisor
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: netvisor
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 0
10
- version: 0.2.0
9
+ - 1
10
+ version: 0.2.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Timo Sand
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2014-09-08 00:00:00 Z
18
+ date: 2014-09-09 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  version_requirements: &id001 !ruby/object:Gem::Requirement