File tree Expand file tree Collapse file tree 3 files changed +27
-1
lines changed Expand file tree Collapse file tree 3 files changed +27
-1
lines changed Original file line number Diff line number Diff line change 6
6
require 'myob/api/models/company_file'
7
7
require 'myob/api/models/contact'
8
8
require 'myob/api/models/customer'
9
+ require 'myob/api/models/employee'
9
10
10
11
require 'myob/api/client'
Original file line number Diff line number Diff line change @@ -12,11 +12,13 @@ def initialize(options)
12
12
model :CompanyFile
13
13
model :Contact
14
14
model :Customer
15
+ model :Employee
15
16
17
+ @redirect_uri = options [ :redirect_uri ]
16
18
@consumer = options [ :consumer ]
17
19
@access_token = options [ :access_token ]
18
20
@refresh_token = options [ :refresh_token ]
19
- @current_company_file = { }
21
+ @current_company_file = options [ :selected_company_file ] || { }
20
22
@client = OAuth2 ::Client . new ( @consumer [ :key ] , @consumer [ :secret ] , {
21
23
:site => 'https://secure.myob.com' ,
22
24
:authorize_url => '/oauth2/account/authorize' ,
@@ -28,6 +30,18 @@ def initialize(options)
28
30
end
29
31
end
30
32
33
+ def get_access_code_url ( params = { } )
34
+ @client . auth_code . authorize_url ( params . merge ( scope : "CompanyFile" , redirect_uri : @redirect_uri ) )
35
+ end
36
+
37
+ def get_access_token ( access_code )
38
+ @token = @client . auth_code . get_token ( access_code , redirect_uri : @redirect_uri )
39
+ @access_token = @token . token
40
+ @expires_at = @token . expires_at
41
+ @refresh_token = @token . refresh_token
42
+ @token
43
+ end
44
+
31
45
def headers
32
46
{
33
47
'x-myobapi-key' => @consumer [ :key ] ,
Original file line number Diff line number Diff line change
1
+ module Myob
2
+ module Api
3
+ module Model
4
+ class Employee < Myob ::Api ::Model ::Base
5
+ def model_route
6
+ 'Contact/Employee'
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
You can’t perform that action at this time.
0 commit comments