Skip to content

Commit 7e7ed69

Browse files
committed
update readme with new functionality
1 parent 106578a commit 7e7ed69

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,33 @@ Or install it yourself as:
1818

1919
## Usage
2020

21+
### OAuth Authentication
22+
23+
If you've already got an OAuth access token, feel free to skip to API Client Setup.
24+
25+
The MYOB API uses 3 legged OAuth2. If you don't want to roll your own, or use the [OmniAuth strategy](https://github.com/davidlumley/omniauth-myob) you can authenticate using the `get_access_code_url` and `get_access_token` methods that [ghiculescu](https://github.com/ghiculescu) has provided like so:
26+
27+
class MYOBSessionController
28+
def new
29+
redirect_to myob_client.get_access_code_url
30+
end
31+
32+
def create
33+
@token = myob_client.get_access_token(params[:code])
34+
@company_files = myob_client.company_file.all
35+
# then show the user a view where they can log in to their company file
36+
end
37+
38+
def myob_client
39+
@api_client = Myob::Api::Client.new({
40+
:consumer => {
41+
:key => YOUR_CONSUMER_KEY,
42+
:secret => YOUR_CONSUMER_SECRET,
43+
},
44+
})
45+
end
46+
end
47+
2148
### API Client Setup
2249

2350
Create an api_client:
@@ -87,6 +114,12 @@ Return a list of all customers (a subset of contacts)
87114

88115
api_client.customer.all
89116

117+
#### Employees
118+
119+
Return a list of all customers (a subset of contacts)
120+
121+
api_client.employee.all
122+
90123

91124
## Todo
92125

0 commit comments

Comments
 (0)