myob-api 0.8 → 0.9

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: fd7d16454a5dd331bfb7ead95ff73e6bca504987
4
- data.tar.gz: 354d7ee0fdfa37a0d467afb72742f50982a1e725
3
+ metadata.gz: 811d5f79a8b26836ec00106c574f869b682521b6
4
+ data.tar.gz: d662c42c636b9558fcecb5230f7e1a4bcabdae35
5
5
  SHA512:
6
- metadata.gz: f509295319d486f9d2a13f726e575d7500af66cafa96a8d4b0d33d4a5f2f27d2bec0551871cbc42ec20aece085ccd68fdca279a03d8eb185e7ec107f883f1107
7
- data.tar.gz: 77e5b218728121d9e7bc75651152746ecaa4b08828af61b1f1453ba273719a25d4385cda1d7730e629c608505fcb1d77d448e588187fb295a9839b72b1306506
6
+ metadata.gz: 07626d4621630fa176b4d10a63fe008ca3aeb2ab0a195d3ed0b238e4a1d73f4bd5e230b4eaf263cd0e2ef84193ef29e6f52eaa09a0c3b6691df6db6f619c2f2a
7
+ data.tar.gz: bc89612b051e0c05cf64302fce29cacbcbcc6a536a7d70bb07a20c798c9a32b0ec28051e84a6ab8529046454f557d4729beac5b5b6997cffe6418795ed1c5742
@@ -40,20 +40,35 @@ module Myob
40
40
  end
41
41
 
42
42
  def headers
43
- {
44
- 'x-myobapi-key' => @consumer[:key],
45
- 'x-myobapi-version' => 'v2',
46
- 'x-myobapi-cftoken' => @current_company_file[:token] || '',
47
- 'Content-Type' => 'application/json'
48
- }
43
+ token = @current_company_file[:token]
44
+ if token.nil? || token == ''
45
+ # if token is blank assume we are using federated login - http://myobapi.tumblr.com/post/109848079164/2015-1-release-notes
46
+ {
47
+ 'x-myobapi-key' => @consumer[:key],
48
+ 'x-myobapi-version' => 'v2',
49
+ 'Content-Type' => 'application/json'
50
+ }
51
+ else
52
+ {
53
+ 'x-myobapi-key' => @consumer[:key],
54
+ 'x-myobapi-version' => 'v2',
55
+ 'x-myobapi-cftoken' => token,
56
+ 'Content-Type' => 'application/json'
57
+ }
58
+ end
49
59
  end
50
60
 
51
61
  def select_company_file(company_file)
52
62
  company_file_id = (self.company_file.all.find {|file| file['Name'] == company_file[:name]} || [])['Id']
53
63
  if company_file_id
64
+ token = company_file[:token]
65
+ if (!token || token == '') && company_file[:username] && company_file[:username] != '' && company_file[:password] && company_file[:password] != ''
66
+ # if we have been given login details, encode them into a token
67
+ token = Base64.encode64("#{company_file[:username]}:#{company_file[:password]}")
68
+ end
54
69
  @current_company_file = {
55
70
  :id => company_file_id,
56
- :token => company_file[:token] || Base64.encode64("#{company_file[:username]}:#{company_file[:password]}"),
71
+ :token => token
57
72
  }
58
73
  end
59
74
  end
@@ -1,5 +1,5 @@
1
1
  module Myob
2
2
  module Api
3
- VERSION = "0.8"
3
+ VERSION = "0.9"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: myob-api
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.8'
4
+ version: '0.9'
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Lumley
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-20 00:00:00.000000000 Z
11
+ date: 2015-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oauth2
@@ -106,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
106
  version: '0'
107
107
  requirements: []
108
108
  rubyforge_project:
109
- rubygems_version: 2.2.0.rc.1
109
+ rubygems_version: 2.4.6
110
110
  signing_key:
111
111
  specification_version: 4
112
112
  summary: MYOB AccountRight Live API V2