Skip to content

Commit bbb25de

Browse files
authored
Merge pull request #9 from RusticiSoftware/enumsAndSwaggerBump
Regenerated library to fix enum issue and add README notes
2 parents f89a941 + 130d7fa commit bbb25de

File tree

151 files changed

+56927
-13413
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

151 files changed

+56927
-13413
lines changed

.php_cs

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
11
<?php
22

3-
return Symfony\CS\Config::create()
4-
->level(Symfony\CS\FixerInterface::PSR2_LEVEL)
3+
return PhpCsFixer\Config::create()
54
->setUsingCache(true)
6-
->fixers(
7-
[
8-
'ordered_use',
9-
'phpdoc_order',
10-
'short_array_syntax',
11-
'strict',
12-
'strict_param'
13-
]
14-
)
15-
->finder(
16-
Symfony\CS\Finder\DefaultFinder::create()
17-
->in(__DIR__)
5+
->setRules([
6+
'@PSR2' => true,
7+
'ordered_imports' => true,
8+
'phpdoc_order' => true,
9+
'array_syntax' => [ 'syntax' => 'short' ],
10+
'strict_comparison' => true,
11+
'strict_param' => true,
12+
'no_trailing_whitespace' => false,
13+
'no_trailing_whitespace_in_comment' => false,
14+
'braces' => false,
15+
'single_blank_line_at_eof' => false,
16+
'blank_line_after_namespace' => false,
17+
])
18+
->setFinder(
19+
PhpCsFixer\Finder::create()
20+
->exclude('test')
21+
->exclude('tests')
22+
->in(__DIR__)
1823
);

README.md

Lines changed: 66 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ REST API used for SCORM Cloud integrations.
44
This PHP package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:
55

66
- API version: 2.0
7-
- Package version: 1.0.1
7+
- Package version: 1.0.2
88
- Build package: io.swagger.codegen.languages.PhpClientCodegen
99

1010
## Requirements
@@ -40,20 +40,77 @@ Download the files and include `autoload.php`:
4040
require_once('/path/to/scormcloud-api-v2-client-php/autoload.php');
4141
```
4242

43+
## Key Considerations
44+
This library is generated using swagger-codegen. When swagger is updated, sometimes changes to the library occur. As a
45+
result of the recent update, service classes are now instantiated slightly differently. You now need to pass a Configuration
46+
object as an argument to the service class' constructor. An example of passing the default configuration is below:
47+
48+
```php
49+
$registration_api = new \RusticiSoftware\Cloud\V2\Api\RegistrationApi(null, RusticiSoftware\Cloud\V2\Configuration::getDefaultConfiguration(), null);
50+
```
51+
52+
If this does not make sense to you, fear not. There is a greater explanation of service classes and configurations below.
53+
54+
It is also worth noting how boolean values need passed in order to function correctly. In functions that consume a boolean argument,
55+
make sure to pass the value as a string. For example, the boolean value of `True` should instead be passed as `'true'`.
56+
4357
## Getting Started
58+
If you are completely new to SCORM Cloud, please read through our [Core Concepts](http://cloud.scorm.com/docs/concepts/)
59+
and the rest of our documentation.
60+
61+
This library adheres to the same specification as our API. As a result, your requests will utilize the service classes
62+
located in the Api folder. Each service class represents a different category of functionality. For example,
63+
adding, deleting, or modifying courses would all be done through functions in CourseApi. You can find examples of
64+
common classes and functions below.
65+
66+
### Configuration
67+
Before you can interact with the API, you will need to set up your authentication credentials.
68+
69+
```php
70+
$config = new RusticiSoftware\Cloud\V2\Configuration();
71+
$config->setUsername('APP_ID');
72+
$config->setPassword('SECRET_KEY');
73+
```
4474

45-
Please follow the [installation procedure](#installation--usage) and then run the following:
75+
### CourseApi
76+
Below is an example of uploading a course to Cloud. Course Service documentation can be found [here](http://cloud.scorm.com/docs/api_reference/v2/endpoints/courseservice/)
77+
78+
```php
79+
$course_api = new \RusticiSoftware\Cloud\V2\Api\CourseApi(null, $config, null);
80+
$course_file = new SplFileObject('path/to/course/file');
81+
$import_token = $course_api->createUploadAndImportCourseJob('COURSE_ID', 'true', null, $course_file)->getResult();
82+
```
83+
84+
### RegistrationApi
85+
Below is an example of creating a very basic registration. Registration Service documentation can be found [here](http://cloud.scorm.com/docs/api_reference/v2/endpoints/registrationservice/)
86+
87+
```php
88+
$registration_api = new \RusticiSoftware\Cloud\V2\Api\RegistrationApi(null, $config, null);
89+
90+
//instantiate a CreateRegistrationSchema that will be passed to createRegistration
91+
$reg_schema = new RusticiSoftware\Cloud\V2\Model\CreateRegistrationSchema();
92+
$reg_schema->setCourseId('COURSE_ID');
93+
$reg_schema->setRegistrationId('REGISTRATION_ID');
94+
95+
$learner_schema = new RusticiSoftware\Cloud\V2\Model\LearnerSchema();
96+
$learner_schema->setId('LEARNER_ID');
97+
98+
$reg_schema->setLearner($learner_schema);
99+
$registration_api->createRegistration($reg_schema);
100+
```
46101

102+
### Starter Script
47103
```php
48104
<?php
49-
require_once(__DIR__ . '/vendor/autoload.php');
105+
require_once('path/to/lib/autoload.php');
50106

51107
// Configure HTTP basic authorization: APP_NORMAL
52-
RusticiSoftware\Cloud\V2\Configuration::getDefaultConfiguration()->setUsername('SCORM_CLOUD_APP_ID');
53-
RusticiSoftware\Cloud\V2\Configuration::getDefaultConfiguration()->setPassword('SECRET_KEY_FOR_APP_ID');
108+
$config = new RusticiSoftware\Cloud\V2\Configuration();
109+
$config->setUsername('APP_ID');
110+
$config->setPassword('SECRET_KEY');
54111

55-
// Then (optionally) further authenticate via Oauth2 token access
56-
$app_management_api = new RusticiSoftware\Cloud\V2\Api\ApplicationManagementApi();
112+
// Further authenticate via Oauth2 token access. This is optional
113+
$app_management_api = new RusticiSoftware\Cloud\V2\Api\ApplicationManagementApi(null, $config, null);
57114

58115
$permissions = new \RusticiSoftware\Cloud\V2\Model\PermissionsSchema([ 'scopes' => ['read:registration']]);
59116
$expiry = new DateTime("now");
@@ -62,10 +119,10 @@ $expiry->modify('+60 minutes');
62119
$token_request = new \RusticiSoftware\Cloud\V2\Model\TokenRequestSchema([ 'permissions' => $permissions, 'expiry' => $expiry]);
63120
try {
64121
$response = $app_management_api->createToken($token_request);
65-
RusticiSoftware\Cloud\V2\Configuration::getDefaultConfiguration()->setAccessToken($response->getResult());
122+
$config->setAccessToken($response->getResult());
66123

67124
// this call will now use Oauth2 with the "read:registration" scope
68-
$registration_api = new \RusticiSoftware\Cloud\V2\Api\RegistrationApi();
125+
$registration_api = new \RusticiSoftware\Cloud\V2\Api\RegistrationApi(null, $config, null);
69126
$registrations_list = $registration_api->getRegistrations();
70127
print_r($registrations_list);
71128
} catch (\RusticiSoftware\Cloud\V2\ApiException $e) {

autoload.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
2+
require_once("vendor/autoload.php");
33
/**
44
* SCORM Cloud Rest API
55
*

composer.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rustici-software/scormcloud-api-v2-client-php",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"description": "",
55
"keywords": [
66
"scorm",
@@ -22,9 +22,10 @@
2222
"php": ">=5.4",
2323
"ext-curl": "*",
2424
"ext-json": "*",
25-
"ext-mbstring": "*"
25+
"ext-mbstring": "*",
26+
"guzzlehttp/guzzle": "~6.0"
2627
},
2728
"autoload": {
2829
"psr-4": { "RusticiSoftware\\Cloud\\V2\\" : "src/" }
2930
}
30-
}
31+
}

0 commit comments

Comments
 (0)