Sha256: d91c6e64766906796cbf579411a9816908474adb55f68adbfb29984969b5282e

Contents?: true

Size: 1.99 KB

Versions: 8

Compression:

Stored size: 1.99 KB

Contents

# PureCloud Ruby Gem
[![Gem Version](https://badge.fury.io/rb/purecloud.svg)](https://badge.fury.io/rb/purecloud)

## Installing

```
gem install PureCloud
```

## Usage
Start by setting the access token in the configuration

```
PureCloud.configure do |config|
  config.access_token = '7oSpBrJ1w2mIf2kDVNJxR3BLzdxsD3hC7hTdG4A8cR50tpcSuxh74SuL4rk_WNqtwkRt2f004eVgXMCVFo84VQ'
  config.host = 'api.mypurecloud.com'
end
```

Specifying the host is optional, it will default to api.mypurecloud.com. This gem contains a number of Api classes e.g. UsersApi, ConfigurationApi. Create an instance of the API you want to use and then you can make calls into the API

```
user_api = PureCloud::UsersApi.new
me = user_api.users_me_get
```

Using the global PureCloud.configure won't work in most situations. In a multiple user environment, you need to create an instance of PureCloud::Configuration and then pass that into the initializer of the api class.

```
config = PureCloud::Configuration.default
config.access_token = authToken;

config_api = PureCloud::ConfigurationApi.new(PureCloud::ApiClient.new( config ))
org = config_api.get_organization
```

### Full Example Using Client Credentials Auth
```
require 'purecloud'

secret = ENV['purecloud_secret']
id = ENV['purecloud_client_id']

PureCloud.authenticate_with_client_credentials id, secret, "mypurecloud.com"

auth_api = PureCloud::AuthorizationApi.new
roles = auth_api.get_roles
puts roles.to_body
```

### Creating an OAuth client
```
oauth_api = PureCloud::OAuthApi.new
opts = {
    #pass a hash into the constructor, these are the same properties that you can find in the rest documentation, not the properties on the OAuthClient object.

    :body=>PureCloud::OAuthClient.new({
            :name => 'Demo Client',
            :description => "",
            :authorizedGrantTypes => ["CLIENT-CREDENTIALS"],
            :roleIds =>["02983623-600c-4779-a0ce-17f79e50e285"]
    })
}

client = oauth_api.create_clients opts
```

For more examples, see the tests in the /tests directory

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
purecloud-0.35.1 README.md
purecloud-0.34.1 README.md
purecloud-0.33.1 README.md
purecloud-0.32.1 README.md
purecloud-0.31.1 README.md
purecloud-0.30.1 README.md
purecloud-0.29.1 README.md
purecloud-0.28.0 README.md