├── .editorconfig
├── .gitattributes
├── .gitignore
├── .project
├── .travis.yml
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── ISSUE_TEMPLATE.md
├── LICENSE
├── PULL_REQUEST_TEMPLATE.md
├── README.md
├── composer.json
├── composer.lock
├── libs
└── phpcs-psr2-stock
│ ├── PSR2Stock
│ ├── Sniffs
│ │ ├── Arrays
│ │ │ └── ArrayDeclarationSniff.php
│ │ ├── Classes
│ │ │ ├── PSR1ClassDeclarationSniff.php
│ │ │ ├── PropertyDeclarationSniff.php
│ │ │ └── ValidClassNameSniff.php
│ │ ├── Commenting
│ │ │ ├── FunctionCommentSniff.php
│ │ │ └── SetAllowedTypesSniff.php
│ │ ├── ControlStructures
│ │ │ ├── ControlSignatureSniff.php
│ │ │ ├── ControlStructureBlankLineSniff.php
│ │ │ ├── ControlStructureSpacingSniff.php
│ │ │ └── ElseIfDeclarationSniff.php
│ │ ├── Functions
│ │ │ └── ValidDefaultValueSniff.php
│ │ ├── Methods
│ │ │ ├── FunctionCallSignatureSniff.php
│ │ │ ├── MethodDeclarationSniff.php
│ │ │ └── ValidFunctionNameSniff.php
│ │ ├── PHP
│ │ │ └── SyntaxSniff.php
│ │ ├── Strings
│ │ │ └── DoubleQuoteUsageSniff.php
│ │ ├── Variables
│ │ │ └── ValidVariableNameSniff.php
│ │ └── Whitespace
│ │ │ └── ControlStructureSpacingSniff.php
│ └── ruleset.xml
│ ├── README.md
│ ├── bin
│ ├── phpcbf-psr2-stock
│ └── phpcs-psr2-stock
│ ├── composer.json
│ └── composer.lock
├── phpunit.xml.dist
├── src
├── Client
│ ├── AdobeStock.php
│ ├── Files.php
│ ├── Http
│ │ ├── HttpClient.php
│ │ └── HttpInterface.php
│ ├── License.php
│ ├── LicenseHistory.php
│ ├── SearchCategory.php
│ └── SearchFiles.php
├── Core
│ ├── Config.php
│ └── Constants.php
├── Exception
│ └── StockApi.php
├── Models
│ ├── LicenseComp.php
│ ├── LicenseContent.php
│ ├── LicenseEntitlement.php
│ ├── LicenseEntitlementQuota.php
│ ├── LicenseMemberInfo.php
│ ├── LicensePurchaseDetails.php
│ ├── LicensePurchaseOptions.php
│ ├── LicenseReference.php
│ ├── LicenseReferenceResponse.php
│ ├── LicenseThumbnail.php
│ ├── SearchParamLicenseHistory.php
│ ├── SearchParameters.php
│ ├── StockFile.php
│ ├── StockFileCompProp.php
│ ├── StockFileComps.php
│ ├── StockFileKeyword.php
│ ├── StockFileLicenseHistory.php
│ ├── StockFileLicenseProp.php
│ └── StockFileLicenses.php
├── Request
│ ├── Files.php
│ ├── License.php
│ ├── LicenseHistory.php
│ ├── SearchCategory.php
│ └── SearchFiles.php
├── Response
│ ├── Files.php
│ ├── License.php
│ ├── LicenseHistory.php
│ ├── SearchCategory.php
│ └── SearchFiles.php
└── Utils
│ └── APIUtils.php
└── test
├── Helper
└── BaseTest.php
├── bootstrap.php
├── resources
├── BigImage.jpg
├── SmallImage.jpg
├── TestFile.png
├── TestFileWidth.png
└── UnsupportedBMP.bmp
└── src
└── Api
├── APIUtils
└── APIUtilsTest.php
├── Client
├── AdobeStockTest.php
├── FilesFactoryTest.php
├── Http
│ └── HttpClientTest.php
├── LicenseFactoryTest.php
├── LicenseHistoryFactoryTest.php
├── SearchCategoryFactoryTest.php
└── SearchFilesFactoryTest.php
├── Core
├── ConfigTest.php
└── ConstantsTest.php
├── Exception
└── StockApiExceptionTest.php
├── Models
├── LicenseCompTest.php
├── LicenseContentTest.php
├── LicenseEntitlementQuotaTest.php
├── LicenseEntitlementTest.php
├── LicenseMemberInfoTest.php
├── LicensePurchaseDetailsTest.php
├── LicensePurchaseOptionsTest.php
├── LicenseReferenceResponseTest.php
├── LicenseReferenceTest.php
├── LicenseThumbnailTest.php
├── SearchParamLicenseHistoryTest.php
├── SearchParametersTest.php
├── StockFileCompPropTest.php
├── StockFileCompsTest.php
├── StockFileKeywordTest.php
├── StockFileLicenseHistoryTest.php
├── StockFileLicensePropTest.php
├── StockFileLicensesTest.php
└── StockFileTest.php
├── Request
├── FilesRequestTest.php
├── LicenseHistoryRequestTest.php
├── LicenseRequestTest.php
├── SearchCategoryRequestTest.php
└── SearchFilesRequestTest.php
└── Response
├── FilesResponseTest.php
├── LicenseHistoryResponseTest.php
├── LicenseResponseTest.php
├── SearchCategoryResponseTest.php
└── SearchFilesResponseTest.php
/.editorconfig:
--------------------------------------------------------------------------------
1 | # editorconfig.org
2 | root = true
3 |
4 | [*]
5 | indent_style = space
6 | indent_size = 4
7 | end_of_line = lf
8 | charset = utf-8
9 | trim_trailing_whitespace = true
10 | insert_final_newline = true
11 |
12 | [*.md]
13 | trim_trailing_whitespace = false
14 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Ignore all differences in line endings
2 | * -crlf
3 |
4 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # composer
2 | /vendor
3 |
4 | # data
5 | /data
6 |
7 | # phpunit
8 | /phpunit.xml
9 |
10 | # ide
11 | .idea/
12 |
13 | # osx
14 | .DS_Store
15 |
16 | # misc
17 | *~
18 | *#
19 | TAGS
20 | .phpunit.result.cache
21 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | PHPSDK
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.php.composer.core.builder.buildPathManagementBuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.wst.common.project.facet.core.builder
15 |
16 |
17 |
18 |
19 | org.eclipse.wst.validation.validationbuilder
20 |
21 |
22 |
23 |
24 | org.eclipse.dltk.core.scriptbuilder
25 |
26 |
27 |
28 |
29 |
30 | org.eclipse.php.core.PHPNature
31 | org.eclipse.wst.common.project.facet.core.nature
32 |
33 |
34 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: php
2 | php:
3 | - 7.3
4 | - 7.4
5 | - 8.0
6 | install: composer install
7 | script: composer run test
8 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Adobe Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | In the interest of fostering an open and welcoming environment, we as
6 | contributors and maintainers pledge to making participation in our project and
7 | our community a harassment-free experience for everyone, regardless of age, body
8 | size, disability, ethnicity, gender identity and expression, level of experience,
9 | nationality, personal appearance, race, religion, or sexual identity and
10 | orientation.
11 |
12 | ## Our Standards
13 |
14 | Examples of behavior that contributes to creating a positive environment
15 | include:
16 |
17 | * Using welcoming and inclusive language
18 | * Being respectful of differing viewpoints and experiences
19 | * Gracefully accepting constructive criticism
20 | * Focusing on what is best for the community
21 | * Showing empathy towards other community members
22 |
23 | Examples of unacceptable behavior by participants include:
24 |
25 | * The use of sexualized language or imagery and unwelcome sexual attention or
26 | advances
27 | * Trolling, insulting/derogatory comments, and personal or political attacks
28 | * Public or private harassment
29 | * Publishing others' private information, such as a physical or electronic
30 | address, without explicit permission
31 | * Other conduct which could reasonably be considered inappropriate in a
32 | professional setting
33 |
34 | ## Our Responsibilities
35 |
36 | Project maintainers are responsible for clarifying the standards of acceptable
37 | behavior and are expected to take appropriate and fair corrective action in
38 | response to any instances of unacceptable behavior.
39 |
40 | Project maintainers have the right and responsibility to remove, edit, or
41 | reject comments, commits, code, wiki edits, issues, and other contributions
42 | that are not aligned to this Code of Conduct, or to ban temporarily or
43 | permanently any contributor for other behaviors that they deem inappropriate,
44 | threatening, offensive, or harmful.
45 |
46 | ## Scope
47 |
48 | This Code of Conduct applies both within project spaces and in public spaces
49 | when an individual is representing the project or its community. Examples of
50 | representing a project or community include using an official project e-mail
51 | address, posting via an official social media account, or acting as an appointed
52 | representative at an online or offline event. Representation of a project may be
53 | further defined and clarified by project maintainers.
54 |
55 | ## Enforcement
56 |
57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
58 | reported by contacting the project team at Grp-opensourceoffice@adobe.com. All
59 | complaints will be reviewed and investigated and will result in a response that
60 | is deemed necessary and appropriate to the circumstances. The project team is
61 | obligated to maintain confidentiality with regard to the reporter of an incident.
62 | Further details of specific enforcement policies may be posted separately.
63 |
64 | Project maintainers who do not follow or enforce the Code of Conduct in good
65 | faith may face temporary or permanent repercussions as determined by other
66 | members of the project's leadership.
67 |
68 | ## Attribution
69 |
70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71 | available at [http://contributor-covenant.org/version/1/4][version]
72 |
73 | [homepage]: http://contributor-covenant.org
74 | [version]: http://contributor-covenant.org/version/1/4/
75 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | Thanks for choosing to contribute!
4 |
5 | The following are a set of guidelines to follow when contributing to this project.
6 |
7 | ## Code Of Conduct
8 |
9 | This project adheres to the Adobe [code of conduct](CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code. Please report unacceptable behavior to stockapis@adobe.com.
10 |
11 | ## Contributor License Agreement
12 |
13 | All third-party contributions to this project must be accompanied by a signed contributor license. This gives Adobe permission to redistribute your contributions as part of the project. Sign our CLA at [opensource.adobe.com/cla.html](http://opensource.adobe.com/cla.html). You only need to submit an Adobe CLA one time, so if you have submitted one previously, you are probably good to go!
14 |
15 | ## Code Reviews
16 |
17 | All submissions should come in the form of pull requests and need to be reviewed by project committers. Read [GitHub's pull request documentation](https://help.github.com/articles/about-pull-requests/) for more information on sending pull requests.
18 |
19 | Lastly, please follow the [pull request template](PULL_REQUEST_TEMPLATE.md) when submitting a pull request!
20 |
--------------------------------------------------------------------------------
/ISSUE_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | # Issue report
2 |
3 | ## URL or PR where issue occurs
4 |
5 |
6 | ## Brief description of issue
7 |
8 |
9 |
10 | ## Proposed fix (if applicable)
11 |
12 |
13 | If you have a proposed solution, please submit a pull request! See the [contributing guidelines](CONTRIBUTING.md), and thanks for your contribution :)
14 |
--------------------------------------------------------------------------------
/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | ## Overview
2 |
3 |
4 | ## Technical Changes
5 |
6 | - Did x because y
7 | - Changed z because x
8 |
9 | ## Screenshot
10 |
11 |
12 | ## Reviewers
13 | - @reviewer1
14 | - @reviewer2
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "astock/stock-api-libphp",
3 | "description": "Adobe Stock API library",
4 | "license": "Apache-2.0",
5 | "repositories": [
6 | {
7 | "type": "vcs",
8 | "url": "./libs/phpcs-psr2-stock"
9 | }
10 | ],
11 | "require": {
12 | "php": ">=7.3",
13 | "guzzlehttp/guzzle": "~7.3"
14 | },
15 | "require-dev": {
16 | "squizlabs/php_codesniffer": "~3.6.0",
17 | "phpunit/phpunit": ">=6.0",
18 | "mockery/mockery": "^1.4.3"
19 | },
20 | "autoload": {
21 | "psr-4": {
22 | "AdobeStock\\Api\\": "src"
23 | }
24 | },
25 | "autoload-dev": {
26 | "psr-4": {
27 | "AdobeStock\\Api\\Test\\": "test"
28 | }
29 | },
30 | "config": {
31 | "bin-dir": "vendor/bin/"
32 | },
33 | "scripts": {
34 | "check": [
35 | "@test",
36 | "@lint"
37 | ],
38 | "lint": "vendor/bin/phpcs --standard='libs/phpcs-psr2-stock/PSR2Stock' src test",
39 | "test": "vendor/bin/phpunit",
40 | "test-coverage": "vendor/bin/phpunit --coverage-html data/clover"
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/libs/phpcs-psr2-stock/PSR2Stock/Sniffs/Classes/PSR1ClassDeclarationSniff.php:
--------------------------------------------------------------------------------
1 |
10 | * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
11 | * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
12 | * @link http://pear.php.net/package/PHP_CodeSniffer
13 | */
14 | namespace PSR2Stock\Sniffs\Classes;
15 |
16 | use \PHP_CodeSniffer\Sniffs\Sniff;
17 | use \PHP_CodeSniffer\Files\File;
18 |
19 | /**
20 | * Class Declaration Test.
21 | *
22 | * Checks the declaration of the class is correct.
23 | *
24 | * @category PHP
25 | * @package PHP_CodeSniffer
26 | * @author Greg Sherwood
27 | * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
28 | * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
29 | * @version Release: 2.3.4
30 | * @link http://pear.php.net/package/PHP_CodeSniffer
31 | */
32 | class PSR1ClassDeclarationSniff implements Sniff
33 | {
34 |
35 |
36 | /**
37 | * Returns an array of tokens this test wants to listen for.
38 | *
39 | * @return array
40 | */
41 | public function register()
42 | {
43 | return array(
44 | T_CLASS,
45 | T_INTERFACE,
46 | T_TRAIT,
47 | );
48 |
49 | }//end register()
50 |
51 |
52 | /**
53 | * Processes this test, when one of its tokens is encountered.
54 | *
55 | * @param File $phpcsFile The file being scanned.
56 | * @param int $stackPtr The position of the current token in the token stack.
57 | *
58 | * @return void
59 | */
60 | public function process(File $phpcsFile, $stackPtr)
61 | {
62 | $tokens = $phpcsFile->getTokens();
63 | if (isset($tokens[$stackPtr]['scope_closer']) === false) {
64 | return;
65 | }
66 |
67 | $errorData = array(strtolower($tokens[$stackPtr]['content']));
68 |
69 | $nextClass = $phpcsFile->findNext(array(T_CLASS, T_INTERFACE, T_TRAIT), ($tokens[$stackPtr]['scope_closer'] + 1));
70 | if ($nextClass !== false) {
71 | $error = 'Each %s must be in a file by itself';
72 | $phpcsFile->addError($error, $nextClass, 'MultipleClasses', $errorData);
73 | $phpcsFile->recordMetric($stackPtr, 'One class per file', 'no');
74 | } else {
75 | $phpcsFile->recordMetric($stackPtr, 'One class per file', 'yes');
76 | }
77 |
78 | $namespace = $phpcsFile->findNext(array(T_NAMESPACE, T_CLASS, T_INTERFACE, T_TRAIT), 0);
79 | if ($tokens[$namespace]['code'] !== T_NAMESPACE) {
80 | // checks first if this is a controller class and then ignore the error
81 | $className = null;
82 | if ($tokens[$namespace]['code'] === T_CLASS) {
83 | $className = $phpcsFile->findNext(T_STRING, $namespace);
84 | }
85 |
86 | if ($className === null || !preg_match('/Controller$/', $tokens[$className]['content'])) {
87 | $error = 'Each %s must be in a namespace of at least one level (a top-level vendor name)';
88 | $phpcsFile->addError($error, $stackPtr, 'MissingNamespace', $errorData);
89 | $phpcsFile->recordMetric($stackPtr, 'Class defined in namespace', 'no');
90 | }
91 | } else {
92 | $phpcsFile->recordMetric($stackPtr, 'Class defined in namespace', 'yes');
93 | }
94 |
95 | }//end process()
96 |
97 |
98 | }//end class
99 |
--------------------------------------------------------------------------------
/libs/phpcs-psr2-stock/PSR2Stock/Sniffs/Classes/PropertyDeclarationSniff.php:
--------------------------------------------------------------------------------
1 |
10 | * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
11 | * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
12 | * @link http://pear.php.net/package/PHP_CodeSniffer
13 | */
14 | namespace PSR2Stock\Sniffs\Classes;
15 |
16 | use \PHP_CodeSniffer\Sniffs\AbstractVariableSniff;
17 | use \PHP_CodeSniffer\Files\File;
18 | use \PHP_CodeSniffer\Util\Tokens;
19 |
20 |
21 | /**
22 | * Verifies that properties are declared correctly.
23 | *
24 | * @category PHP
25 | * @package PHP_CodeSniffer
26 | * @author Greg Sherwood
27 | * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
28 | * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
29 | * @version Release: 2.3.4
30 | * @link http://pear.php.net/package/PHP_CodeSniffer
31 | */
32 | class PropertyDeclarationSniff extends AbstractVariableSniff
33 | {
34 |
35 |
36 | /**
37 | * Processes the function tokens within the class.
38 | *
39 | * @param File $phpcsFile The file where this token was found.
40 | * @param int $stackPtr The position where the token was found.
41 | *
42 | * @return void
43 | */
44 | protected function processMemberVar(File $phpcsFile, $stackPtr)
45 | {
46 | $tokens = $phpcsFile->getTokens();
47 |
48 | // Detect multiple properties defined at the same time. Throw an error
49 | // for this, but also only process the first property in the list so we don't
50 | // repeat errors.
51 | $find = Tokens::$scopeModifiers;
52 | $find = array_merge($find, array(T_VARIABLE, T_VAR, T_SEMICOLON));
53 | $prev = $phpcsFile->findPrevious($find, ($stackPtr - 1));
54 | if ($tokens[$prev]['code'] === T_VARIABLE) {
55 | return;
56 | }
57 |
58 | if ($tokens[$prev]['code'] === T_VAR) {
59 | $error = 'The var keyword must not be used to declare a property';
60 | $phpcsFile->addError($error, $stackPtr, 'VarUsed');
61 | }
62 |
63 | $next = $phpcsFile->findNext(array(T_VARIABLE, T_SEMICOLON), ($stackPtr + 1));
64 | if ($tokens[$next]['code'] === T_VARIABLE) {
65 | $error = 'There must not be more than one property declared per statement';
66 | $phpcsFile->addError($error, $stackPtr, 'Multiple');
67 | }
68 |
69 | $modifier = $phpcsFile->findPrevious(Tokens::$scopeModifiers, $stackPtr);
70 | if (($modifier === false) || ($tokens[$modifier]['line'] !== $tokens[$stackPtr]['line'])) {
71 | $error = 'Visibility must be declared on property "%s"';
72 | $data = array($tokens[$stackPtr]['content']);
73 | $phpcsFile->addError($error, $stackPtr, 'ScopeMissing', $data);
74 | }
75 |
76 | if ($modifier) {
77 | if ($tokens[$modifier]['content'] == 'public') {
78 | $underscore_prefix = false;
79 | } else {
80 | $underscore_prefix = true;
81 | }
82 |
83 | $first_char = substr($tokens[$stackPtr]['content'], 1, 1);
84 | if ($first_char == '_' && !$underscore_prefix) {
85 | $error = 'A public property name cannot start with "_"';
86 | $phpcsFile->addError($error, $stackPtr, 'VarNaming');
87 | } else if ($first_char != '_' && $underscore_prefix) {
88 | $error = 'A non public property name must start with "_"';
89 | $phpcsFile->addError($error, $stackPtr, 'VarNaming');
90 | }
91 | }
92 |
93 | }//end processMemberVar()
94 |
95 |
96 | /**
97 | * Processes normal variables.
98 | *
99 | * @param File $phpcsFile The file where this token was found.
100 | * @param int $stackPtr The position where the token was found.
101 | *
102 | * @return void
103 | */
104 | protected function processVariable(File $phpcsFile, $stackPtr)
105 | {
106 | /*
107 | We don't care about normal variables.
108 | */
109 |
110 | }//end processVariable()
111 |
112 |
113 | /**
114 | * Processes variables in double quoted strings.
115 | *
116 | * @param File $phpcsFile The file where this token was found.
117 | * @param int $stackPtr The position where the token was found.
118 | *
119 | * @return void
120 | */
121 | protected function processVariableInString(File $phpcsFile, $stackPtr)
122 | {
123 | /*
124 | We don't care about normal variables.
125 | */
126 |
127 | }//end processVariableInString()
128 |
129 |
130 | }//end class
131 |
--------------------------------------------------------------------------------
/libs/phpcs-psr2-stock/PSR2Stock/Sniffs/Classes/ValidClassNameSniff.php:
--------------------------------------------------------------------------------
1 |
10 | * @author Marc McIntyre
11 | * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
12 | * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
13 | * @link http://pear.php.net/package/PHP_CodeSniffer
14 | */
15 | namespace PSR2Stock\Sniffs\Classes;
16 |
17 | use \PHP_CodeSniffer\Sniffs\Sniff;
18 | use \PHP_CodeSniffer\Files\File;
19 | use \PHP_CodeSniffer\Util\Common;
20 |
21 | /**
22 | * ValidClassNameSniff.
23 | *
24 | * Ensures classes are in camel caps, and the first letter is capitalised
25 | *
26 | * @category PHP
27 | * @package PHP_CodeSniffer
28 | * @author Greg Sherwood
29 | * @author Marc McIntyre
30 | * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
31 | * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
32 | * @version Release: 2.3.4
33 | * @link http://pear.php.net/package/PHP_CodeSniffer
34 | */
35 | class ValidClassNameSniff implements Sniff
36 | {
37 |
38 |
39 | /**
40 | * Returns an array of tokens this test wants to listen for.
41 | *
42 | * @return array
43 | */
44 | public function register()
45 | {
46 | return array(
47 | T_CLASS,
48 | T_INTERFACE,
49 | );
50 |
51 | }//end register()
52 |
53 |
54 | /**
55 | * Processes this test, when one of its tokens is encountered.
56 | *
57 | * @param File $phpcsFile The current file being processed.
58 | * @param int $stackPtr The position of the current token in the stack passed in $tokens.
59 | *
60 | * @return void
61 | */
62 | public function process(File $phpcsFile, $stackPtr)
63 | {
64 | $tokens = $phpcsFile->getTokens();
65 |
66 | if (isset($tokens[$stackPtr]['scope_opener']) === false) {
67 | $error = 'Possible parse error: %s missing opening or closing brace';
68 | $data = array($tokens[$stackPtr]['content']);
69 | $phpcsFile->addWarning($error, $stackPtr, 'MissingBrace', $data);
70 | return;
71 | }
72 |
73 | // Determine the name of the class or interface. Note that we cannot
74 | // simply look for the first T_STRING because a class name
75 | // starting with the number will be multiple tokens.
76 | $opener = $tokens[$stackPtr]['scope_opener'];
77 | $nameStart = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), $opener, true);
78 | $nameEnd = $phpcsFile->findNext(T_WHITESPACE, $nameStart, $opener);
79 | if ($nameEnd === false) {
80 | $name = $tokens[$nameStart]['content'];
81 | } else {
82 | $name = trim($phpcsFile->getTokensAsString($nameStart, ($nameEnd - $nameStart)));
83 | }
84 |
85 | // Check for camel caps format.
86 | $valid = Common::isCamelCaps($name, true, true, false);
87 | if ($valid === false) {
88 | // ignore the error for module prefixed ZF controllers
89 | if (!preg_match('/^\w+_\w+Controller$/', $name)) {
90 | $type = ucfirst($tokens[$stackPtr]['content']);
91 | $error = '%s name "%s" is not in camel caps format';
92 | $data = array(
93 | $type,
94 | $name,
95 | );
96 | $phpcsFile->addError($error, $stackPtr, 'NotCamelCaps', $data);
97 | $phpcsFile->recordMetric($stackPtr, 'CamelCase class name', 'no');
98 | } else {
99 | $phpcsFile->recordMetric($stackPtr, 'CamelCase class name', 'no');
100 | }
101 | } else {
102 | $phpcsFile->recordMetric($stackPtr, 'CamelCase class name', 'yes');
103 | }
104 |
105 | }//end process()
106 |
107 |
108 | }//end class
109 |
--------------------------------------------------------------------------------
/libs/phpcs-psr2-stock/PSR2Stock/Sniffs/Commenting/SetAllowedTypesSniff.php:
--------------------------------------------------------------------------------
1 | gettokens();
38 | $previoustoken = $stackptr - 1;
39 |
40 | // Move back until we find the previous non-whitespace, non-comment token
41 | do {
42 | $previoustoken = $phpcsfile->findprevious(array(T_WHITESPACE, T_COMMENT, T_DOC_COMMENT),
43 | ($previoustoken - 1), null, true);
44 |
45 | } while ($tokens[$previoustoken]['line'] == $tokens[$stackptr]['line']);
46 |
47 | $previous_non_ws_token = $tokens[$previoustoken];
48 |
49 | $previous_token = $tokens[$phpcsfile->findprevious(
50 | array(T_WHITESPACE, T_COMMENT, T_DOC_COMMENT),
51 | ($stackptr - 1), null, true)
52 | ];
53 |
54 | // If this token is immediately on the line before this control structure, print a warning
55 | if ($previous_non_ws_token['line'] == ($tokens[$stackptr]['line'] - 1)) {
56 | // Exception: do {EOL...} while (...);
57 | if ($tokens[$stackptr]['code'] == T_WHILE && $tokens[($stackptr - 1)]['code'] == T_CLOSE_CURLY_BRACKET) {
58 | // Ignore do...while (see above)
59 | } else if (
60 | $previous_non_ws_token['code'] == T_OPEN_CURLY_BRACKET
61 | || $previous_non_ws_token['content'] == ':'
62 | || $previous_non_ws_token['code'] == T_CLOSE_CURLY_BRACKET
63 | || $previous_token['code'] == T_ELSE
64 | ) {
65 | // if the previous token is an open bracket just ignore
66 | } else {
67 | $fix = $phpcsfile->addFixableError('You should add a blank line before control structures', $stackptr, 'NoLineBeforeControlStructure');
68 |
69 | if ($fix === true) {
70 | $phpcsfile->fixer->beginChangeset();
71 | $phpcsfile->fixer->addNewlineBefore($stackptr - 1);
72 | $phpcsfile->fixer->endChangeset();
73 | }
74 | }
75 | }
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/libs/phpcs-psr2-stock/PSR2Stock/Sniffs/ControlStructures/ElseIfDeclarationSniff.php:
--------------------------------------------------------------------------------
1 |
10 | * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
11 | * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
12 | * @link http://pear.php.net/package/PHP_CodeSniffer
13 | */
14 | namespace PSR2Stock\Sniffs\ControlStructures;
15 |
16 | use \PHP_CodeSniffer\Sniffs\Sniff;
17 | use \PHP_CodeSniffer\Files\File;
18 |
19 | /**
20 | * PSR2_Sniffs_ControlStructures_ElseIfDeclarationSniff.
21 | *
22 | * Verifies that there are no else if statements. Elseif should be used instead.
23 | *
24 | * @category PHP
25 | * @package PHP_CodeSniffer
26 | * @author Greg Sherwood
27 | * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
28 | * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
29 | * @version Release: 2.3.4
30 | * @link http://pear.php.net/package/PHP_CodeSniffer
31 | */
32 | class ElseIfDeclarationSniff implements Sniff
33 | {
34 |
35 |
36 | /**
37 | * Returns an array of tokens this test wants to listen for.
38 | *
39 | * @return array
40 | */
41 | public function register()
42 | {
43 | return array(
44 | T_ELSEIF,
45 | );
46 |
47 | }//end register()
48 |
49 |
50 | /**
51 | * Processes this test, when one of its tokens is encountered.
52 | *
53 | * @param File $phpcsFile The file being scanned.
54 | * @param int $stackPtr The position of the current token in the stack passed in $tokens.
55 | *
56 | * @return void
57 | */
58 | public function process(File $phpcsFile, $stackPtr)
59 | {
60 | $tokens = $phpcsFile->getTokens();
61 |
62 | if ($tokens[$stackPtr]['code'] === T_ELSEIF) {
63 | $phpcsFile->recordMetric($stackPtr, 'Use of ELSE IF or ELSEIF', 'elseif');
64 | $error = 'Usage of ELSEIF is discouraged; use ELSE IF instead';
65 | $fix = $phpcsFile->addFixableWarning($error, $stackPtr, 'NotAllowed');
66 |
67 | if ($fix === true) {
68 | $phpcsFile->fixer->beginChangeset();
69 | $phpcsFile->fixer->replaceToken($stackPtr, 'else if');
70 | $phpcsFile->fixer->endChangeset();
71 | }
72 | }
73 | }//end process()
74 |
75 |
76 | }//end class
77 |
--------------------------------------------------------------------------------
/libs/phpcs-psr2-stock/PSR2Stock/Sniffs/Functions/ValidDefaultValueSniff.php:
--------------------------------------------------------------------------------
1 |
10 | * @author Marc McIntyre
11 | * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
12 | * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
13 | * @link http://pear.php.net/package/PHP_CodeSniffer
14 | */
15 | namespace PSR2Stock\Sniffs\Functions;
16 |
17 | use \PHP_CodeSniffer\Sniffs\Sniff;
18 | use \PHP_CodeSniffer\Files\File;
19 | use \PHP_CodeSniffer\Util\Tokens;
20 |
21 | /**
22 | * PEAR_Sniffs_Functions_ValidDefaultValueSniff.
23 | *
24 | * A Sniff to ensure that parameters defined for a function that have a default
25 | * value come at the end of the function signature.
26 | *
27 | * @category PHP
28 | * @package PHP_CodeSniffer
29 | * @author Greg Sherwood
30 | * @author Marc McIntyre
31 | * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
32 | * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
33 | * @version Release: 2.3.4
34 | * @link http://pear.php.net/package/PHP_CodeSniffer
35 | */
36 | class ValidDefaultValueSniff implements Sniff
37 | {
38 |
39 |
40 | /**
41 | * Returns an array of tokens this test wants to listen for.
42 | *
43 | * @return array
44 | */
45 | public function register()
46 | {
47 | return array(T_FUNCTION);
48 |
49 | }//end register()
50 |
51 |
52 | /**
53 | * Processes this test, when one of its tokens is encountered.
54 | *
55 | * @param File $phpcsFile The file being scanned.
56 | * @param int $stackPtr The position of the current token in the stack passed in $tokens.
57 | *
58 | * @return void
59 | */
60 | public function process(File $phpcsFile, $stackPtr)
61 | {
62 | $tokens = $phpcsFile->getTokens();
63 |
64 | $argStart = $tokens[$stackPtr]['parenthesis_opener'];
65 | $argEnd = $tokens[$stackPtr]['parenthesis_closer'];
66 |
67 | // Flag for when we have found a default in our arg list.
68 | // If there is a value without a default after this, it is an error.
69 | $defaultFound = false;
70 |
71 | $nextArg = $argStart;
72 | while (($nextArg = $phpcsFile->findNext(T_VARIABLE, ($nextArg + 1), $argEnd)) !== false) {
73 | if ($tokens[($nextArg - 1)]['code'] === T_ELLIPSIS) {
74 | continue;
75 | }
76 |
77 | $argHasDefault = self::_argHasDefault($phpcsFile, $nextArg);
78 | if ($argHasDefault === false && $defaultFound === true) {
79 | $error = 'Arguments with default values must be at the end of the argument list';
80 | $phpcsFile->addError($error, $nextArg, 'NotAtEnd');
81 | return;
82 | }
83 |
84 | if ($argHasDefault === true) {
85 | $defaultFound = true;
86 | }
87 | }
88 |
89 | }//end process()
90 |
91 |
92 | /**
93 | * Returns true if the passed argument has a default value.
94 | *
95 | * @param File $phpcsFile The file being scanned.
96 | * @param int $argPtr The position of the argument in the stack.
97 | *
98 | * @return bool
99 | */
100 | private static function _argHasDefault(File $phpcsFile, $argPtr)
101 | {
102 | $tokens = $phpcsFile->getTokens();
103 | $nextToken = $phpcsFile->findNext(Tokens::$emptyTokens, ($argPtr + 1), null, true);
104 | if ($tokens[$nextToken]['code'] !== T_EQUAL) {
105 | return false;
106 | }
107 |
108 | // ignore if there's a type hinting
109 | $previousToken = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($argPtr - 1), null, true);
110 | if ($previousToken && $tokens[$previousToken]['code'] === T_STRING || $tokens[$previousToken]['code'] === T_OPEN_PARENTHESIS) {
111 | return false;
112 | }
113 |
114 | return true;
115 |
116 | }//end _argHasDefault()
117 |
118 |
119 | }//end class
120 |
--------------------------------------------------------------------------------
/libs/phpcs-psr2-stock/PSR2Stock/Sniffs/Methods/FunctionCallSignatureSniff.php:
--------------------------------------------------------------------------------
1 |
10 | * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
11 | * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
12 | * @link http://pear.php.net/package/PHP_CodeSniffer
13 | */
14 | namespace PSR2Stock\Sniffs\Methods;
15 |
16 | use \PHP_CodeSniffer\Files\File;
17 | use \PHP_CodeSniffer\Util\Tokens;
18 | use \PHP_CodeSniffer\Standards\PSR2\Sniffs\Methods\FunctionCallSignatureSniff as PSR2FunctionCallSignatureSniff;
19 |
20 |
21 | /**
22 | * FunctionCallSignatureSniff.
23 | *
24 | * @category PHP
25 | * @package PHP_CodeSniffer
26 | * @author Greg Sherwood
27 | * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
28 | * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
29 | * @version Release: 2.3.4
30 | * @link http://pear.php.net/package/PHP_CodeSniffer
31 | */
32 | class FunctionCallSignatureSniff extends PSR2FunctionCallSignatureSniff
33 | {
34 |
35 | /**
36 | * If TRUE, multiple arguments can be defined per line in a multi-line call.
37 | *
38 | * @var bool
39 | */
40 | public $allowMultipleArguments = false;
41 |
42 |
43 | /**
44 | * Processes single-line calls.
45 | *
46 | * @param File $phpcsFile The file being scanned.
47 | * @param int $stackPtr The position of the current token in the stack passed in $tokens.
48 | * @param int $openBracket The position of the opening bracket in the stack passed in $tokens.
49 | * @param array $tokens The stack of tokens that make up the file.
50 | *
51 | * @return void
52 | */
53 | public function isMultiLineCall(File $phpcsFile, $stackPtr, $openBracket, $tokens)
54 | {
55 | // If the first argument is on a new line, this is a multi-line
56 | // function call, even if there is only one argument.
57 | $next = $phpcsFile->findNext(Tokens::$emptyTokens, ($openBracket + 1), null, true);
58 | if ($tokens[$next]['line'] !== $tokens[$stackPtr]['line']) {
59 | return true;
60 | }
61 |
62 | $closeBracket = $tokens[$openBracket]['parenthesis_closer'];
63 |
64 | $end = $phpcsFile->findEndOfStatement($openBracket + 1);
65 | while ($tokens[$end]['code'] === T_COMMA) {
66 | // If the next bit of code is not on the same line, this is a
67 | // multi-line function call.
68 | $next = $phpcsFile->findNext(Tokens::$emptyTokens, ($end + 1), $closeBracket, true);
69 | if ($next === false) {
70 | return false;
71 | }
72 |
73 | if ($tokens[$next]['line'] !== $tokens[$end]['line']) {
74 | return true;
75 | }
76 |
77 | $end = $phpcsFile->findEndOfStatement($next);
78 | }
79 |
80 | // We've reached the last argument, so see if the next content
81 | // (should be the close bracket) is also on the same line.
82 | $next = $phpcsFile->findNext(Tokens::$emptyTokens, ($end + 1), $closeBracket, true);
83 | if ($next !== false && $tokens[$next]['line'] !== $tokens[$end]['line']) {
84 | return true;
85 | }
86 |
87 | return false;
88 |
89 | }//end isMultiLineCall()
90 |
91 |
92 | }//end class
93 |
--------------------------------------------------------------------------------
/libs/phpcs-psr2-stock/PSR2Stock/Sniffs/PHP/SyntaxSniff.php:
--------------------------------------------------------------------------------
1 |
10 | * @author Greg Sherwood
11 | * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
12 | * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
13 | * @link http://pear.php.net/package/PHP_CodeSniffer
14 | */
15 | namespace PSR2Stock\Sniffs\PHP;
16 |
17 | use \PHP_CodeSniffer\Sniffs\Sniff;
18 | use \PHP_CodeSniffer\Files\File;
19 |
20 |
21 | /**
22 | * SyntaxSniff
23 | *
24 | * Ensures PHP believes the syntax is clean.
25 | *
26 | * @category PHP
27 | * @package PHP_CodeSniffer
28 | * @author Blaine Schmeisser
29 | * @author Greg Sherwood
30 | * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
31 | * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
32 | * @version Release: 2.5.1
33 | * @link http://pear.php.net/package/PHP_CodeSniffer
34 | */
35 | class SyntaxSniff implements Sniff
36 | {
37 |
38 |
39 | /**
40 | * Returns an array of tokens this test wants to listen for.
41 | *
42 | * @return array
43 | */
44 | public function register()
45 | {
46 | return array(T_OPEN_TAG);
47 |
48 | }//end register()
49 |
50 |
51 | /**
52 | * Processes this test, when one of its tokens is encountered.
53 | *
54 | * @param File $phpcsFile The file being scanned.
55 | * @param int $stackPtr The position of the current token in the stack passed in $tokens.
56 | *
57 | * @return void
58 | */
59 | public function process(File $phpcsFile, $stackPtr)
60 | {
61 | $fileName = $phpcsFile->getFilename();
62 | $cmd = "php -l \"$fileName\" 2>&1";
63 | $output = shell_exec($cmd);
64 |
65 | $matches = array();
66 | if (preg_match('/^.*error:(.*) in .* on line ([0-9]+)/', trim($output), $matches) === 1) {
67 | $error = trim($matches[1]);
68 | $line = (int) $matches[2];
69 | $phpcsFile->addErrorOnLine("PHP syntax error: $error", $line, 'PHPSyntax');
70 | }
71 |
72 | // Ignore the rest of the file.
73 | return ($phpcsFile->numTokens + 1);
74 |
75 | }//end process()
76 |
77 |
78 | }//end class
79 |
--------------------------------------------------------------------------------
/libs/phpcs-psr2-stock/README.md:
--------------------------------------------------------------------------------
1 | # Adobe Stock PHP coding style validator
2 |
3 | PHP coding style checker for all Adobe Stock PHP code [Adobe Stock](https://stock.adobe.com)
4 |
5 | ## Description
6 |
7 | All PHP code submitted into the Stock php repositories needs to be validated against this standard.
8 | It relies on the [PSR2 standard](http://www.php-fig.org/psr/psr-2/) with some adjustments and adds.
9 |
10 | ## Usage
11 |
12 | First you need to install the require dependencies by running `composer install`.
13 |
14 | Then you can run the checker it this way:
15 | ```
16 | bin/phpcs-psr2-stock
17 | ```
18 |
19 | You can also run the fixer it this way:
20 | ```
21 | bin/phpcbf-psr2-stock
22 | ```
23 |
24 | ## Installation using composer
25 |
26 | You can include this repository into another project using [composer](https://getcomposer.org/) by copying the `libs` folder and adding the following configuration into your `composer.json` file:
27 | ```
28 | {
29 | "require-dev": {
30 | "astock/phpcs-psr2-stock": "~1.4"
31 | },
32 | "repositories": [
33 | {
34 | "type": "vcs",
35 | "url": "./libs/phpcs-psr2-stock"
36 | }
37 | ],
38 | }
39 | ```
40 |
--------------------------------------------------------------------------------
/libs/phpcs-psr2-stock/bin/phpcbf-psr2-stock:
--------------------------------------------------------------------------------
1 | phpcs-psr2-stock
--------------------------------------------------------------------------------
/libs/phpcs-psr2-stock/bin/phpcs-psr2-stock:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | if [ $(basename $0) = "phpcbf-psr2-stock" ]; then
4 | CMD=phpcbf
5 | else
6 | CMD=phpcs
7 | fi
8 |
9 | if [ -d $(dirname $0)/../PSR2Stock ]; then
10 | # standard usage
11 | $(dirname $0)/../vendor/bin/${CMD} --standard=$(dirname $0)/../PSR2Stock $@
12 | else
13 | # vendor/bin usage
14 | $(dirname $0)/${CMD} --standard=$(dirname $0)/../astock/phpcs-psr2-stock/PSR2Stock $@
15 | fi
16 |
--------------------------------------------------------------------------------
/libs/phpcs-psr2-stock/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "astock/phpcs-psr2-stock",
3 | "description": "Adobe Stock PHP coding style validator",
4 | "license": "proprietary",
5 | "authors": [
6 | {
7 | "name": "Olivier Sirven",
8 | "email": "sirven@adobe.com"
9 | }
10 | ],
11 | "require": {
12 | "squizlabs/php_codesniffer": "~3.1"
13 | },
14 | "config": {
15 | "bin-dir": "vendor/bin/"
16 | },
17 | "bin": [
18 | "bin/phpcs-psr2-stock",
19 | "bin/phpcbf-psr2-stock"
20 | ]
21 | }
22 |
--------------------------------------------------------------------------------
/libs/phpcs-psr2-stock/composer.lock:
--------------------------------------------------------------------------------
1 | {
2 | "_readme": [
3 | "This file locks the dependencies of your project to a known state",
4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
5 | "This file is @generated automatically"
6 | ],
7 | "content-hash": "f358efb29afda4221c9e06f081f91aa0",
8 | "packages": [
9 | {
10 | "name": "squizlabs/php_codesniffer",
11 | "version": "3.1.0",
12 | "source": {
13 | "type": "git",
14 | "url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
15 | "reference": "3c2d0a0fe39684ba0c1eb842a6a775d0b938d699"
16 | },
17 | "dist": {
18 | "type": "zip",
19 | "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/3c2d0a0fe39684ba0c1eb842a6a775d0b938d699",
20 | "reference": "3c2d0a0fe39684ba0c1eb842a6a775d0b938d699",
21 | "shasum": ""
22 | },
23 | "require": {
24 | "ext-simplexml": "*",
25 | "ext-tokenizer": "*",
26 | "ext-xmlwriter": "*",
27 | "php": ">=5.4.0"
28 | },
29 | "require-dev": {
30 | "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0"
31 | },
32 | "bin": [
33 | "bin/phpcs",
34 | "bin/phpcbf"
35 | ],
36 | "type": "library",
37 | "extra": {
38 | "branch-alias": {
39 | "dev-master": "3.x-dev"
40 | }
41 | },
42 | "notification-url": "https://packagist.org/downloads/",
43 | "license": [
44 | "BSD-3-Clause"
45 | ],
46 | "authors": [
47 | {
48 | "name": "Greg Sherwood",
49 | "role": "lead"
50 | }
51 | ],
52 | "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.",
53 | "homepage": "http://www.squizlabs.com/php-codesniffer",
54 | "keywords": [
55 | "phpcs",
56 | "standards"
57 | ],
58 | "time": "2017-09-19T22:47:14+00:00"
59 | }
60 | ],
61 | "packages-dev": [],
62 | "aliases": [],
63 | "minimum-stability": "stable",
64 | "stability-flags": [],
65 | "prefer-stable": false,
66 | "prefer-lowest": false,
67 | "platform": [],
68 | "platform-dev": []
69 | }
70 |
--------------------------------------------------------------------------------
/phpunit.xml.dist:
--------------------------------------------------------------------------------
1 |
2 |
15 |
16 |
17 |
18 | ./test/src/
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | ./src
28 |
29 |
30 | ./vendor
31 | ./test
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/src/Client/Files.php:
--------------------------------------------------------------------------------
1 | _config = $config;
34 | }
35 |
36 | /**
37 | * Method to create and send request to the apis and parse result to response object.
38 | *
39 | * @param FilesRequest $file_request object containing files request parameters
40 | * @param HttpClientInterface $http_client
41 | * @param string $access_token access token string to be used with api calls
42 | * @return FilesResponse response object from the api call
43 | * @throws StockApiException
44 | */
45 | public function getFiles(
46 | FilesRequest $file_request,
47 | HttpClientInterface $http_client,
48 | ?string $access_token = null
49 | ) : FilesResponse {
50 | $this->_validateRequest($file_request, $access_token);
51 | $response_json = $http_client->doGet(
52 | $this->_getUrl($file_request),
53 | APIUtils::generateCommonAPIHeaders($this->_config, $access_token)
54 | );
55 | $files_response = new FilesResponse();
56 | $files_response->initializeResponse(json_decode($response_json, true));
57 | return $files_response;
58 | }
59 |
60 | /**
61 | * Method to validate request.
62 | *
63 | * @param FilesRequest $request
64 | * @param string $access_token
65 | * @throws StockApiException
66 | */
67 | private function _validateRequest(FilesRequest $request, ?string $access_token = null) : void
68 | {
69 | if (!empty($request->getResultColumns())) {
70 | if (in_array('is_licensed', $request->getResultColumns()) && $access_token === null) {
71 | throw StockApiException::withMessage(
72 | 'Access Token missing! Result Column is_licensed requires authentication'
73 | );
74 | }
75 | }
76 | }
77 |
78 | /**
79 | * Build request URL with parameters
80 | *
81 | * @param FilesRequest $filesRequest
82 | * @return string
83 | */
84 | private function _getUrl(FilesRequest $filesRequest) : string
85 | {
86 | return $this->_config->getEndPoints()['files'] . '?' . http_build_query($filesRequest->toArray());
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/src/Client/Http/HttpInterface.php:
--------------------------------------------------------------------------------
1 | _config = $config;
34 | }
35 |
36 | /**
37 | * Get information about a category of Stock assets, such as travel
38 | * or animals for a specified category identifier, optionally localized.
39 | * @param SearchCategoryRequest $request object containing
40 | * category-id and locale
41 | * @param string $access_token Users ims access token
42 | * @param HttpClientInterface $http_client client that to be used in calling apis.
43 | * @return SearchCategoryResponse consists of is, name and link of the asset category.
44 | * @throws StockException if category id is not set.
45 | */
46 | public function getCategory(SearchCategoryRequest $request, string $access_token, HttpClientInterface $http_client) : SearchCategoryResponse
47 | {
48 | if ($request->getCategoryId() === null) {
49 | throw StockApiException::withMessage('Category Id cannot be null');
50 | }
51 |
52 | $end_point = $this->_config->getEndPoints()['category'];
53 | $request_url = $end_point . '?' . http_build_query($request);
54 | $headers = APIUtils::generateCommonAPIHeaders($this->_config, $access_token);
55 | $raw_response = $http_client->doGet($request_url, $headers);
56 | $search_category_response = new SearchCategoryResponse(json_decode($raw_response, true));
57 | return $search_category_response;
58 | }
59 |
60 | /**
61 | * Get category information for zero or more category identifiers.
62 | * If you request information without specifying a category, this returns a list of all stock categories
63 | * @param SearchCategoryRequest $request object containing category-id and locale
64 | * @param string $access_token Users ims access token
65 | * @param HttpClientInterface $http_client client that to be used in calling apis.
66 | * @throws StockApiException if category id is not set.
67 | * @return array list of SearchCategoryResponse
68 | */
69 | public function getCategoryTree(SearchCategoryRequest $request, string $access_token, HttpClientInterface $http_client) : array
70 | {
71 | if ($request->getCategoryId() == null) {
72 | throw StockApiException::withMessage('Category Id cannot be null');
73 | }
74 |
75 | $end_point = $this->_config->getEndPoints()['category_tree'];
76 | $request_url = $end_point . '?' . http_build_query($request);
77 | $headers = APIUtils::generateCommonAPIHeaders($this->_config, $access_token);
78 | $raw_response = $http_client->doGet($request_url, $headers);
79 | return $this->_createSearchCategoryResponseArray(json_decode($raw_response, true));
80 | }
81 |
82 | /**
83 | * Util function to convert json array to SearchCategoryResponse Array.
84 | * @param array $response_array raw response.
85 | * @return array list of SearchCategoryResponse objects
86 | */
87 | private function _createSearchCategoryResponseArray(array $response_array) : array
88 | {
89 | $search_category_response_array = [];
90 |
91 | foreach ($response_array as $response) {
92 | $search_category_response = new SearchCategoryResponse($response);
93 | $search_category_response_array[] = $search_category_response;
94 | }
95 |
96 | return $search_category_response_array;
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/src/Core/Config.php:
--------------------------------------------------------------------------------
1 | _target_env = $environment[$env];
56 | $this->_endpoints = $end_points;
57 | } else {
58 | $this->_target_env = $environment['STAGE'];
59 | $this->_endpoints = str_replace('stock', 'stock-stage', $end_points);
60 | }
61 |
62 | if ($api_key !== null) {
63 | $this->_api_key = $api_key;
64 | }
65 |
66 | if ($product !== null) {
67 | $this->_product = $product;
68 | }
69 | }
70 |
71 | /**
72 | * Returns the api key.
73 | * @return string
74 | */
75 | public function getapiKey() : string
76 | {
77 | return $this->_api_key;
78 | }
79 |
80 | /**
81 | * Returns the product.
82 | * @return string
83 | */
84 | public function getProduct() : string
85 | {
86 | return $this->_product;
87 | }
88 |
89 | /**
90 | * Returns the targetEnv.
91 | * @return string
92 | */
93 | public function getTargetEnv() : string
94 | {
95 | return $this->_target_env;
96 | }
97 |
98 | /**
99 | * Returns the endPoint.
100 | * @return array
101 | */
102 | public function getEndPoints() : array
103 | {
104 | return $this->_endpoints;
105 | }
106 |
107 | /**
108 | * Set the api_key.
109 | * @param string $val api key.
110 | * @return Config
111 | */
112 | public function setApiKey(string $val) : Config
113 | {
114 | $this->_api_key = $val;
115 | return $this;
116 | }
117 |
118 | /**
119 | * Set the Product.
120 | * @param string $val product.
121 | * @return Config
122 | */
123 | public function setProduct(string $val) : Config
124 | {
125 | $this->_product = $val;
126 | return $this;
127 | }
128 |
129 | /**
130 | * Set the targetEnv.
131 | * @param string $val
132 | * @return Config
133 | */
134 | public function setTargetEnv(string $val) : Config
135 | {
136 | $this->_target_env = $val;
137 | return $this;
138 | }
139 |
140 | /**
141 | * Set the EndPoint.
142 | * @param array $val endpoint.
143 | * @return Config
144 | */
145 | public function setEndPoints(array $val) : Config
146 | {
147 | $this->_endpoints = $val;
148 | return $this;
149 | }
150 |
151 | /**
152 | * Checks if the config is initialized/set
153 | * @return bool true if config is initialized/set, false otherwise
154 | */
155 | public function isConfigInitialized() : bool
156 | {
157 | return ($this->_target_env && $this->_endpoints && $this->_api_key && $this->_product);
158 | }
159 | }
160 |
--------------------------------------------------------------------------------
/src/Exception/StockApi.php:
--------------------------------------------------------------------------------
1 | $val) {
62 | if (property_exists($this, $key)) {
63 | $this->$key = $val;
64 | }
65 | }
66 | }
67 |
68 | /**
69 | * Getter for URL
70 | * @return string
71 | */
72 | public function getUrl(): string
73 | {
74 | return $this->url;
75 | }
76 |
77 | /**
78 | * Getter for Content Type
79 | * @return string
80 | */
81 | public function getContentType(): string
82 | {
83 | return $this->content_type;
84 | }
85 |
86 | /**
87 | * Getter for width
88 | * @return int
89 | */
90 | public function getWidth(): int
91 | {
92 | return $this->width;
93 | }
94 |
95 | /**
96 | * Getter for frame rate
97 | * @return float
98 | */
99 | public function getFrameRate() : float
100 | {
101 | return $this->frame_rate;
102 | }
103 |
104 | /**
105 | * Getter for height
106 | * @return int
107 | */
108 | public function getHeight(): int
109 | {
110 | return $this->height;
111 | }
112 |
113 | /**
114 | * Getter for content length
115 | * @return int
116 | */
117 | public function getContentLength(): int
118 | {
119 | return $this->content_length;
120 | }
121 |
122 | /**
123 | * Getter for duration
124 | * @return int
125 | */
126 | public function getDuration(): int
127 | {
128 | return $this->duration;
129 | }
130 |
131 | /**
132 | * Setter for URL
133 | * @param string $val
134 | * @return LicenseComp
135 | */
136 | public function setUrl(string $val) : LicenseComp
137 | {
138 | $this->url = $val;
139 | return $this;
140 | }
141 |
142 | /**
143 | * Setter for Content Type
144 | * @param string $val
145 | * @return LicenseComp
146 | */
147 | public function setContentType(string $val) : LicenseComp
148 | {
149 | $this->content_type = $val;
150 | return $this;
151 | }
152 |
153 | /**
154 | * Setter for width
155 | * @param int $val
156 | * @return LicenseComp
157 | */
158 | public function setWidth(int $val) : LicenseComp
159 | {
160 | $this->width = $val;
161 | return $this;
162 | }
163 |
164 | /**
165 | * Setter for frame rate
166 | * @param float $val
167 | * @return LicenseComp
168 | */
169 | public function setFrameRate(float $val) : LicenseComp
170 | {
171 | $this->frame_rate = $val;
172 | return $this;
173 | }
174 |
175 | /**
176 | * Setter for height
177 | * @param int $val
178 | * @return LicenseComp
179 | */
180 | public function setHeight(int $val) : LicenseComp
181 | {
182 | $this->height = $val;
183 | return $this;
184 | }
185 |
186 | /**
187 | * Setter for content length
188 | * @param int $val
189 | * @return LicenseComp
190 | */
191 | public function setContentLength(int $val) : LicenseComp
192 | {
193 | $this->content_length = $val;
194 | return $this;
195 | }
196 |
197 | /**
198 | * Setter for duration
199 | * @param int $val
200 | * @return LicenseComp
201 | */
202 | public function setDuration(int $val) : LicenseComp
203 | {
204 | $this->duration = $val;
205 | return $this;
206 | }
207 | }
208 |
--------------------------------------------------------------------------------
/src/Models/LicenseContent.php:
--------------------------------------------------------------------------------
1 | $val) {
57 | if (property_exists($this, $key)) {
58 | if ($key == 'purchase_details') {
59 | $this->purchase_details = new LicensePurchaseDetails($val);
60 | } else if ($key == 'comp') {
61 | $this->comp = new LicenseComp($val);
62 | } else if ($key == 'thumbnail') {
63 | $this->thumbnail = new LicenseThumbnail($val);
64 | } else {
65 | $this->$key = $val;
66 | }
67 | }
68 | }
69 | }
70 |
71 | /**
72 | * Getter for ContentId
73 | * @return string
74 | */
75 | public function getContentId(): string
76 | {
77 | return $this->content_id;
78 | }
79 |
80 | /**
81 | * Getter for user's purchase/license details
82 | * @return LicensePurchaseDetails|null
83 | */
84 | public function getPurchaseDetails(): ?LicensePurchaseDetails
85 | {
86 | return $this->purchase_details;
87 | }
88 |
89 | /**
90 | * Getter for size of the asset, indicating whether it is the free
91 | * complementary size or the original full-sized asset.
92 | * @return string
93 | */
94 | public function getSize(): string
95 | {
96 | return $this->size;
97 | }
98 |
99 | /**
100 | * Get Information about the complementary or watermarked asset.
101 | * @return LicenseComp|null
102 | */
103 | public function getComp(): ?LicenseComp
104 | {
105 | return $this->comp;
106 | }
107 |
108 | /**
109 | * Get information about the asset thumbnail.
110 | * @return LicenseThumbnail|null
111 | */
112 | public function getThumbnail(): ?LicenseThumbnail
113 | {
114 | return $this->thumbnail;
115 | }
116 |
117 | /**
118 | * Setter for ContentId
119 | * @param string $val
120 | * @return LicenseContent
121 | */
122 | public function setContentId(string $val) : LicenseContent
123 | {
124 | $this->content_id = $val;
125 | return $this;
126 | }
127 |
128 | /**
129 | * Setter for user's purchase/license details
130 | * @param LicensePurchaseDetails $val
131 | * @return LicenseContent
132 | */
133 | public function setPurchaseDetails(LicensePurchaseDetails $val) : LicenseContent
134 | {
135 | $this->purchase_details = $val;
136 | return $this;
137 | }
138 |
139 | /**
140 | * Seter for size
141 | * @param string $val
142 | * @return LicenseContent
143 | */
144 | public function setSize(string $val) : LicenseContent
145 | {
146 | $size = CoreConstants::getAssetLicenseSize();
147 |
148 | if (array_key_exists($val, $size)) {
149 | $this->size = $size[$val];
150 | } else {
151 | throw StockApiException::withMessage('This Size doesn\'t exist');
152 | }
153 |
154 | return $this;
155 | }
156 |
157 | /**
158 | * Set Information about the complementary or watermarked asset.
159 | * @param LicenseComp $val
160 | * @return LicenseContent
161 | */
162 | public function setComp(LicenseComp $val) : LicenseContent
163 | {
164 | $this->comp = $val;
165 | return $this;
166 | }
167 |
168 | /**
169 | * Set information about the asset thumbnail.
170 | * @param LicenseThumbnail $val
171 | * @return LicenseContent
172 | */
173 | public function setThumbnail(LicenseThumbnail $val) : LicenseContent
174 | {
175 | $this->thumbnail = $val;
176 | return $this;
177 | }
178 | }
179 |
--------------------------------------------------------------------------------
/src/Models/LicenseEntitlementQuota.php:
--------------------------------------------------------------------------------
1 | $val) {
51 | $this->$key = $val;
52 | }
53 | }
54 |
55 | /**
56 | * Get Image quota for CCI, CCT and CCE 1st and 2nd generation.
57 | * @return int image quota
58 | */
59 | public function getImageQuota() : int
60 | {
61 | return $this->image_quota;
62 | }
63 |
64 | /**
65 | * Get Video quota for CCE 1st generation.
66 | * @return int video quota
67 | */
68 | public function getVideoQuota() : int
69 | {
70 | return $this->video_quota;
71 | }
72 |
73 | /**
74 | * Get Credits quota for CCE 2nd generation.
75 | * @return int credits quota
76 | */
77 | public function getCreditsQuota() : int
78 | {
79 | return $this->credits_quota;
80 | }
81 |
82 | /**
83 | * Get Standard credits quota for CCE 3rd generation.
84 | * @return int standard credits quota
85 | */
86 | public function getStandardCreditQuota() : int
87 | {
88 | return $this->standard_credits_quota;
89 | }
90 |
91 | /**
92 | * Get Premium credits quota for CCE 3rd generation.
93 | * @return int premium credits quota
94 | */
95 | public function getPremiumCreditsQuota() : int
96 | {
97 | return $this->premium_credits_quota;
98 | }
99 |
100 | /**
101 | * Get Universal credits quota for CCE 3rd generation.
102 | * @return int universal credits quota
103 | */
104 | public function getUniversalCreditsQuota() : int
105 | {
106 | return $this->universal_credits_quota;
107 | }
108 |
109 | /**
110 | * Setter for ImageQuota.
111 | * @param int $quota
112 | * @return LicenseEntitlementQuota
113 | */
114 | public function setImageQuota(int $quota) : LicenseEntitlementQuota
115 | {
116 | $this->image_quota = $quota;
117 | return $this;
118 | }
119 |
120 | /**
121 | * Setter for VideoQuota.
122 | * @param int $quota
123 | * @return LicenseEntitlementQuota
124 | */
125 | public function setVideoQuota(int $quota) : LicenseEntitlementQuota
126 | {
127 | $this->video_quota = $quota;
128 | return $this;
129 | }
130 |
131 | /**
132 | * Setter for CreditsQuota.
133 | * @param int $quota
134 | * @return LicenseEntitlementQuota
135 | */
136 | public function setCreditsQuota(int $quota) : LicenseEntitlementQuota
137 | {
138 | $this->credits_quota = $quota;
139 | return $this;
140 | }
141 |
142 | /**
143 | * Setter for StandardCreditsQuota.
144 | * @param int $quota
145 | * @return LicenseEntitlementQuota
146 | */
147 | public function setStandardCreditQuota(int $quota) : LicenseEntitlementQuota
148 | {
149 | $this->standard_credits_quota = $quota;
150 | return $this;
151 | }
152 |
153 | /**
154 | * Setter for PremiumCreditsQuota.
155 | * @param int $quota
156 | * @return LicenseEntitlementQuota
157 | */
158 | public function setPremiumCreditsQuota(int $quota) : LicenseEntitlementQuota
159 | {
160 | $this->premium_credits_quota = $quota;
161 | return $this;
162 | }
163 |
164 | /**
165 | * Setter for UniversalCreditsQuota.
166 | * @param int $quota
167 | * @return LicenseEntitlementQuota
168 | */
169 | public function setUniversalCreditsQuota(int $quota) : LicenseEntitlementQuota
170 | {
171 | $this->universal_credits_quota = $quota;
172 | return $this;
173 | }
174 | }
175 |
--------------------------------------------------------------------------------
/src/Models/LicenseMemberInfo.php:
--------------------------------------------------------------------------------
1 | $val) {
26 | if (property_exists($this, $key)) {
27 | $this->$key = $val;
28 | }
29 | }
30 | }
31 |
32 | /**
33 | * Get user's Adobe Stock member identifier.
34 | * @return string
35 | */
36 | public function getStockId(): string
37 | {
38 | return $this->stock_id;
39 | }
40 |
41 | /**
42 | * Sets Adobe Stock member identifier.
43 | * @param string $val
44 | * @return LicenseMemberInfo
45 | */
46 | public function setStockId(string $val) : LicenseMemberInfo
47 | {
48 | $this->stock_id = $val;
49 | return $this;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/Models/LicensePurchaseOptions.php:
--------------------------------------------------------------------------------
1 | $val) {
44 | if (property_exists($this, $key)) {
45 | $this->$key = $val;
46 | }
47 | }
48 | }
49 |
50 | /**
51 | * Get user's purchase relationship to an asset.
52 | * @return asset purchase state
53 | */
54 | public function getPurchaseState(): string
55 | {
56 | return $this->state;
57 | }
58 |
59 | /**
60 | * Get whether a purchase in process requires going to
61 | * the Adobe Stock site for completion.
62 | * @return true if requires going to Adobe Stock site else false
63 | */
64 | public function getRequiresCheckout(): bool
65 | {
66 | return $this->requires_checkout;
67 | }
68 |
69 | /**
70 | * Get Message to display to your user in response to a licensing API query.
71 | * @return message of type String
72 | */
73 | public function getMessage(): string
74 | {
75 | return $this->message;
76 | }
77 |
78 | /**
79 | * Get the URL to see purchase options plan.
80 | * @return string
81 | */
82 | public function getPurchaseUrl(): string
83 | {
84 | return $this->url;
85 | }
86 |
87 | /**
88 | * Sets user's purchase relationship to an asset.
89 | * @param string $purchase_state specifying asset purchase status
90 | * @return LicensePurchaseOptions
91 | */
92 | public function setPurchaseState(string $purchase_state) : LicensePurchaseOptions
93 | {
94 | $state = CoreConstants::getPurchaseStateParams();
95 |
96 | if (array_key_exists($purchase_state, $state)) {
97 | $this->state = $state[$purchase_state];
98 | } else {
99 | throw StockApiException::withMessage('No such purchase state exists');
100 | }
101 |
102 | return $this;
103 | }
104 |
105 | /**
106 | * Sets whether a purchase in process requires going to
107 | * the Adobe Stock site for completion.
108 | * @param bool $val
109 | * @return LicensePurchaseOptions
110 | */
111 | public function setRequiresCheckout(bool $val) : LicensePurchaseOptions
112 | {
113 | $this->requires_checkout = $val;
114 | return $this;
115 | }
116 |
117 | /**
118 | * Sets Message to display to your user in response to a
119 | * licensing API query.
120 | * @param string $val
121 | * @return LicensePurchaseOptions
122 | */
123 | public function setMessage(string $val) : LicensePurchaseOptions
124 | {
125 | $this->message = $val;
126 | return $this;
127 | }
128 |
129 | /**
130 | * Sets the URL to see purchase options plan.
131 | * @param string $val
132 | * @return LicensePurchaseOptions
133 | */
134 | public function setPurchaseUrl(string $val) : LicensePurchaseOptions
135 | {
136 | $this->url = $val;
137 | return $this;
138 | }
139 | }
140 |
--------------------------------------------------------------------------------
/src/Models/LicenseReference.php:
--------------------------------------------------------------------------------
1 | $val) {
35 | if (property_exists($this, $key)) {
36 | $this->$key = $val;
37 | }
38 | }
39 | }
40 |
41 | /**
42 | * Getter for license reference id.
43 | * @return int
44 | */
45 | public function getLicenseReferenceId(): int
46 | {
47 | return $this->id;
48 | }
49 |
50 | /**
51 | * Setter for License Reference Id
52 | * @param int $val
53 | * @return LicenseReference
54 | */
55 | public function setLicenseReferenceId(int $val): LicenseReference
56 | {
57 | if ($val < 0) {
58 | throw StockApiException::withMessage('License Reference id cannot be negative');
59 | }
60 |
61 | $this->id = $val;
62 | return $this;
63 | }
64 |
65 | /**
66 | * Getter for license reference value.
67 | * @return string
68 | */
69 | public function getLicenseReferenceValue(): string
70 | {
71 | return $this->value;
72 | }
73 |
74 | /**
75 | * Setter for license reference value.
76 | * @param string $val
77 | * @return LicenseReference
78 | */
79 | public function setLicenseReferenceValue(string $val): LicenseReference
80 | {
81 | if (empty($val)) {
82 | throw StockApiException::withMessage('License Reference value cannot be empty');
83 | }
84 |
85 | $this->value = $val;
86 | return $this;
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/src/Models/LicenseReferenceResponse.php:
--------------------------------------------------------------------------------
1 | id;
37 | }
38 |
39 | /**
40 | * @param int $val
41 | * @return LicenseReferenceResponse
42 | */
43 | public function setLicenseReferenceId(int $val) : LicenseReferenceResponse
44 | {
45 | $this->id = $val;
46 | return $this;
47 | }
48 |
49 | /**
50 | * Get whether license reference must be submitted
51 | * when licensing the image.
52 | * @return true if license reference must be submitted else false
53 | */
54 | public function getRequired(): bool
55 | {
56 | return $this->required;
57 | }
58 |
59 | /**
60 | * Sets whether license reference must be submitted
61 | * when licensing the image.
62 | * @param bool $val , required true if license reference must be submitted else false
63 | * @return LicenseReferenceResponse
64 | */
65 | public function setRequired(bool $val) : LicenseReferenceResponse
66 | {
67 | $this->required = $val;
68 | return $this;
69 | }
70 |
71 | /**
72 | * Get License reference description.
73 | * @return description of type String.
74 | */
75 | public function getText(): string
76 | {
77 | return $this->text;
78 | }
79 |
80 | /**
81 | * Sets License reference description.
82 | * @param string $val
83 | * @return LicenseReferenceResponse
84 | */
85 | public function setText(string $val) : LicenseReferenceResponse
86 | {
87 | $this->text = $val;
88 | return $this;
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/src/Models/LicenseThumbnail.php:
--------------------------------------------------------------------------------
1 | $val) {
44 | if (property_exists($this, $key)) {
45 | $this->$key = $val;
46 | }
47 | }
48 | }
49 |
50 | /**
51 | * Getter for asset URL
52 | * @return string
53 | */
54 | public function getUrl(): string
55 | {
56 | return $this->url;
57 | }
58 |
59 | /**
60 | * Getter for asset Content Type
61 | * @return string
62 | */
63 | public function getContentType(): string
64 | {
65 | return $this->content_type;
66 | }
67 |
68 | /**
69 | * Getter for asset Width
70 | * @return int
71 | */
72 | public function getWidth(): int
73 | {
74 | return $this->width;
75 | }
76 |
77 | /**
78 | * Getter for asset Height
79 | * @return int
80 | */
81 | public function getHeight(): int
82 | {
83 | return $this->height;
84 | }
85 |
86 | /**
87 | * Setter for asset URL
88 | * @param string $val
89 | * @return LicenseThumbnail
90 | */
91 | public function setUrl(string $val) : LicenseThumbnail
92 | {
93 | $this->url = $val;
94 | return $this;
95 | }
96 |
97 | /**
98 | * Setter for asset Content Type
99 | * @param string $val
100 | * @return LicenseThumbnail
101 | */
102 | public function setContentType(string $val) : LicenseThumbnail
103 | {
104 | $this->content_type = $val;
105 | return $this;
106 | }
107 |
108 | /**
109 | * Setter for asset Width
110 | * @param int $val
111 | * @return LicenseThumbnail
112 | */
113 | public function setWidth(int $val) : LicenseThumbnail
114 | {
115 | $this->width = $val;
116 | return $this;
117 | }
118 |
119 | /**
120 | * Setter for asset Height
121 | * @param int $val
122 | * @return LicenseThumbnail
123 | */
124 | public function setHeight(int $val) : LicenseThumbnail
125 | {
126 | $this->height = $val;
127 | return $this;
128 | }
129 | }
130 |
--------------------------------------------------------------------------------
/src/Models/SearchParamLicenseHistory.php:
--------------------------------------------------------------------------------
1 | limit;
48 | }
49 |
50 | /**
51 | * Sets maximum number of assets in search Params that you wants to return
52 | * in the api call.
53 | * @param int $limit maximum number of assets that return in the api call
54 | * @return SearchParamLicenseHistory object
55 | * @throws StockApiException if limit is less than 1
56 | */
57 | public function setLimit(int $limit) : SearchParamLicenseHistory
58 | {
59 | if ($limit < static::MIN_LIMIT) {
60 | throw StockApiException::WithMessage('Limit should be greater than 0');
61 | }
62 |
63 | $this->limit = $limit;
64 | return $this;
65 | }
66 |
67 | /**
68 | * Get start position(index) in search results.
69 | * @return int|null offset of type function
70 | */
71 | public function getOffset() : ?int
72 | {
73 | return $this->offset;
74 | }
75 |
76 | /**
77 | * Sets the start position(index) in search results.
78 | * @param int $offset starting index in the search results
79 | * @return SearchParamLicenseHistory object
80 | * @throws StockApiException if offset is not positive
81 | */
82 | public function setOffset(int $offset) : SearchParamLicenseHistory
83 | {
84 | if ($offset < 0) {
85 | throw StockApiException::WithMessage('Offset should be greater than 0');
86 | }
87 |
88 | $this->offset = $offset;
89 | return $this;
90 | }
91 |
92 | /**
93 | * Get Thumbnail Size in search results.
94 | * @return int|null
95 | */
96 | public function getThumbnailSize() : ?int
97 | {
98 | return $this->thumbnail_size;
99 | }
100 |
101 | /**
102 | * Sets the thumbnail size in search results.
103 | * @param int $thumbnail_size
104 | * @return SearchParamLicenseHistory object
105 | * @throws StockApiException if Invalid thumbnail size
106 | */
107 | public function setThumbnailSize(int $thumbnail_size) : SearchParamLicenseHistory
108 | {
109 | $size = CoreConstants::getSearchParamsLicenseThumbSizes();
110 |
111 | if (array_key_exists($thumbnail_size, $size)) {
112 | $this->thumbnail_size = $size[$thumbnail_size];
113 | } else {
114 | throw StockApiException::WithMessage('Invalid Thumbnail size');
115 | }
116 |
117 | return $this;
118 | }
119 | }
120 |
--------------------------------------------------------------------------------
/src/Models/StockFileCompProp.php:
--------------------------------------------------------------------------------
1 | $val) {
37 | if (property_exists($this, $key)) {
38 | $this->$key = $val;
39 | }
40 | }
41 | }
42 |
43 | /**
44 | * Get width of complementary image.
45 | * @return int|null
46 | */
47 | public function getWidth() : ?int
48 | {
49 | return $this->width;
50 | }
51 |
52 | /**
53 | * Sets width of complementary image.
54 | * @param int $width
55 | * @return StockFileCompProp
56 | */
57 | public function setWidth(?int $width = null)
58 | {
59 | $this->width = $width;
60 | return $this;
61 | }
62 |
63 | /**
64 | * Get height of complementary image.
65 | * @return int|null
66 | */
67 | public function getHeight() : ?int
68 | {
69 | return $this->height;
70 | }
71 |
72 | /**
73 | * Sets Height of complementary image.
74 | * @param int $height
75 | * @return StockFileCompProp
76 | */
77 | public function setHeight(?int $height = null) : StockFileCompProp
78 | {
79 | $this->height = $height;
80 | return $this;
81 | }
82 |
83 | /**
84 | * Get url of complementary image.
85 | * @return string|null
86 | */
87 | public function getUrl() : string
88 | {
89 | return $this->url;
90 | }
91 | /**
92 | * Sets url of complementary image.
93 | * @param string $url url of complementary image.
94 | * @return StockFileCompProp
95 | */
96 | public function setUrl(?string $url = null) : StockFileCompProp
97 | {
98 | $this->url = $url;
99 | return $this;
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/src/Models/StockFileComps.php:
--------------------------------------------------------------------------------
1 | 'standard',
39 | 'Video_HD' => 'video_hd',
40 | 'Video_4K' => 'video_4k',
41 | ];
42 |
43 | /**
44 | * Constructor for StockFileCompPropModels
45 | * @param array $raw_response Array contains value of various keys of StockFileComps Class
46 | */
47 | public function __construct(array $raw_response)
48 | {
49 | foreach ($raw_response as $key => $val) {
50 |
51 | if (property_exists($this, $this->json_mapper[$key])) {
52 |
53 | if (is_array($val)) {
54 | $this->json_mapper[$key] = new StockFileCompPropModels($val);
55 | }
56 | }
57 | }
58 | }
59 |
60 | /**
61 | * Get Standard format property of complementary asset.
62 | * @return StockFileCompPropModels
63 | */
64 | public function getStandard() : StockFileCompPropModels
65 | {
66 | return $this->standard;
67 | }
68 |
69 | /**
70 | * Get Video_HD format property of complementary asset.
71 | * @return StockFileCompPropModels
72 | */
73 | public function getVideoHD() : StockFileCompPropModels
74 | {
75 | return $this->video_hd;
76 | }
77 |
78 | /**
79 | * Get Video_4k format property of complementary asset.
80 | * @return StockFileCompPropModels
81 | */
82 | public function getVideo4K() : StockFileCompPropModels
83 | {
84 | return $this->video_4k;
85 | }
86 |
87 | /**
88 | * Sets Standard format property of complementary asset.
89 | * @param StockFileCompPropModels $standard
90 | * @return StockFileComps
91 | */
92 | public function setStandard(StockFileCompPropModels $standard) : StockFileComps
93 | {
94 | $this->standard = $standard;
95 | return $this;
96 | }
97 |
98 | /**
99 | * Sets Video_HD format property of complementary asset.
100 | * @param StockFileCompPropModels $video_hd
101 | * @return StockFileComps
102 | */
103 | public function setVideoHD(StockFileCompPropModels $video_hd) : StockFileComps
104 | {
105 | $this->video_hd = $video_hd;
106 | return $this;
107 | }
108 |
109 | /**
110 | * Sets Video_4k format property of complementary asset.
111 | * @param StockFileCompPropModels $video_4k
112 | * @return StockFileComps
113 | */
114 | public function setVideo4K(StockFileCompPropModels $video_4k) : StockFileComps
115 | {
116 | $this->video_4k = $video_4k;
117 | return $this;
118 | }
119 | }
120 |
--------------------------------------------------------------------------------
/src/Models/StockFileKeyword.php:
--------------------------------------------------------------------------------
1 | $val) {
26 | if (property_exists($this, $key)) {
27 | $this->$key = $val;
28 | }
29 | }
30 | }
31 |
32 | /**
33 | * Get name of media keyword.
34 | * @return string|null
35 | */
36 | public function getName() : ?string
37 | {
38 | return $this->name;
39 | }
40 |
41 | /**
42 | * Sets name of media keyword.
43 | * @param string $name name of media keyword
44 | * @return StockFileKeyword
45 | */
46 | public function setName(?string $name = null) : StockFileKeyword
47 | {
48 | $this->name = $name;
49 | return $this;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/Models/StockFileLicenseProp.php:
--------------------------------------------------------------------------------
1 | $val) {
38 | if (property_exists($this, $key)) {
39 | $this->$key = $val;
40 | }
41 | }
42 | }
43 |
44 | /**
45 | * Get width property of license.
46 | * @return int|null width
47 | */
48 | public function getWidth() : ?int
49 | {
50 | return $this->width;
51 | }
52 |
53 | /**
54 | * Sets width property of license.
55 | * @param int $Width Width
56 | * @return StockFileLicenseProp
57 | */
58 | public function setWidth(?int $Width = null) : StockFileLicenseProp
59 | {
60 | $this->width = $Width;
61 | return $this;
62 | }
63 |
64 | /**
65 | * Get height property of license.
66 | * @return int|null height
67 | */
68 | public function getHeight() : ?int
69 | {
70 | return $this->height;
71 | }
72 |
73 | /**
74 | * Sets height property of license.
75 | * @param int $height Height
76 | * @return StockFileLicenseProp
77 | */
78 | public function setHeight(?int $height = null) : StockFileLicenseProp
79 | {
80 | $this->height = $height;
81 | return $this;
82 | }
83 |
84 | /**
85 | * Get licensing url.
86 | * @return string|null url
87 | */
88 | public function getUrl() : ?string
89 | {
90 | return $this->url;
91 | }
92 |
93 | /**
94 | * Sets licensing url.
95 | * @param string $url url of complementary image
96 | * @return StockFileLicenseProp
97 | */
98 | public function setUrl(?string $url = null) : StockFileLicenseProp
99 | {
100 | $this->url = $url;
101 | return $this;
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/src/Models/StockFileLicenses.php:
--------------------------------------------------------------------------------
1 | 'standard',
33 | 'Standard_M' => 'standard_m',
34 | ];
35 |
36 | /**
37 | * Constructor for StockFileLicenses
38 | * @param array $raw_response Array contains value of various keys of StockFileLicenses Class
39 | */
40 | public function __construct(array $raw_response)
41 | {
42 | foreach ($raw_response as $key => $val) {
43 |
44 | if (property_exists($this, $this->json_mapper[$key])) {
45 | if (is_array($val)) {
46 | $this->json_mapper[$key] = new StockFileLicensePropModels($val);
47 | }
48 | }
49 | }
50 | }
51 |
52 | /**
53 | * Get Standard license type.
54 | * @return StockFileLicensePropModels
55 | */
56 | public function getstandard() : StockFileLicensePropModels
57 | {
58 | return $this->standard;
59 | }
60 |
61 | /**
62 | * Get half-priced premium license type.
63 | * @return StockFileLicensePropModels
64 | */
65 | public function getStandardM() : StockFileLicensePropModels
66 | {
67 | return $this->standard_m;
68 | }
69 |
70 | /**
71 | * Sets Standard license type.
72 | * @param StockFileLicensePropModels $standard
73 | * @return StockFileLicenses
74 | */
75 | public function setStandard(StockFileLicensePropModels $standard) : StockFileLicenses
76 | {
77 | $this->standard = $standard;
78 | return $this;
79 | }
80 |
81 | /**
82 | * Sets half-priced premium license type.
83 | * @param StockFileLicensePropModels $standard_m
84 | * @return StockFileLicenses
85 | */
86 | public function setStandardM(StockFileLicensePropModels $standard_m) : StockFileLicenses
87 | {
88 | $this->standard_m = $standard_m;
89 | return $this;
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/src/Request/Files.php:
--------------------------------------------------------------------------------
1 | ids;
39 | }
40 |
41 | /**
42 | * @param array $ids
43 | * @return Files
44 | */
45 | public function setIds(array $ids) : Files
46 | {
47 | $this->ids = $ids;
48 | return $this;
49 | }
50 |
51 | /**
52 | * Getter for Locale.
53 | * @return string|null Language location code.
54 | */
55 | public function getLocale() : ?string
56 | {
57 | return $this->locale;
58 | }
59 |
60 | /**
61 | * Setter for Locale.
62 | * @param string $locale Language location code.
63 | * @return Files
64 | */
65 | public function setLocale(string $locale) : Files
66 | {
67 | $this->locale = $locale;
68 | return $this;
69 | }
70 |
71 | /**
72 | * Get ResultColumns array that you have included for columns
73 | * @return array|null
74 | */
75 | public function getResultColumns() : ?array
76 | {
77 | return $this->result_columns;
78 | }
79 |
80 | /**
81 | * Set ResultColumns array consisting of result column constants
82 | * @param array $result_columns
83 | * @return Files
84 | */
85 | public function setResultColumns(array $result_columns) : Files
86 | {
87 | $this->result_columns = $result_columns;
88 | return $this;
89 | }
90 |
91 | /**
92 | * Transforms object to array
93 | *
94 | * @return array
95 | */
96 | public function toArray()
97 | {
98 | return [
99 | Constants::getQueryParamsProps()['IDS'] => implode(',', $this->ids),
100 | Constants::getQueryParamsProps()['LOCALE'] => $this->locale,
101 | Constants::getQueryParamsProps()['RESULT_COLUMNS'] => $this->result_columns
102 | ];
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/src/Request/LicenseHistory.php:
--------------------------------------------------------------------------------
1 | locale;
38 | }
39 |
40 | /**
41 | * Setter for Locale.
42 | * @param string $locale Language location code.
43 | * @throws StockApiException if locale is null
44 | * @return LicenseHistory
45 | */
46 | public function setLocale(?string $locale = null) : LicenseHistory
47 | {
48 | if ($locale === null) {
49 | throw StockApiException::withMessage('Locale cannot be null');
50 | }
51 |
52 | $this->locale = $locale;
53 | return $this;
54 | }
55 |
56 | /**
57 | * Get SearchParameters array that consists of various search params
58 | * @return SearchParamLicenseHistoryModel|null
59 | */
60 | public function getSearchParams() : ?SearchParamLicenseHistoryModel
61 | {
62 | return $this->search_parameters;
63 | }
64 |
65 | /**
66 | * Sets SearchParameters object that consists of various search params
67 | * @param SearchParamLicenseHistoryModel $search_parameters
68 | * @throws StockApiException
69 | * @return LicenseHistory
70 | */
71 | public function setSearchParams(?SearchParamLicenseHistoryModel $search_parameters = null) : LicenseHistory
72 | {
73 | if ($search_parameters === null) {
74 | throw StockApiException::withMessage('SearchParams array cannot be null');
75 | }
76 |
77 | $this->search_parameters = $search_parameters;
78 | return $this;
79 | }
80 |
81 | /**
82 | * Get ResultColumns array that you have included for columns
83 | * @return array|null
84 | */
85 | public function getResultColumns() : ?array
86 | {
87 | return $this->result_columns;
88 | }
89 |
90 | /**
91 | * Set ResultColumns array consisting of result column constants
92 | * @param array $result_columns
93 | * @throws StockApiException
94 | * @return LicenseHistory
95 | */
96 | public function setResultColumns(?array $result_columns = null) : LicenseHistory
97 | {
98 | if (empty($result_columns)) {
99 | throw StockApiException::withMessage('ResultColumns array cannot be empty');
100 | }
101 |
102 | $this->result_columns = $result_columns;
103 | return $this;
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/src/Request/SearchCategory.php:
--------------------------------------------------------------------------------
1 | locale;
34 | }
35 |
36 | /**
37 | * Setter for Locale.
38 | * @param string $locale Language location code.
39 | * @return SearchCategory
40 | * @throws StockApiException if locale is empty.
41 | */
42 | public function setLocale(string $locale) : SearchCategory
43 | {
44 | if (!empty($locale)) {
45 | $this->locale = $locale;
46 | } else {
47 | throw StockApiException::withMessage('Locale cannot be empty string');
48 | }
49 |
50 | return $this;
51 | }
52 |
53 | /**
54 | * Getter for CategoryId.
55 | * @return int|null Unique identifier for an existing category.
56 | */
57 | public function getCategoryId() : ?int
58 | {
59 | return $this->category_id;
60 | }
61 |
62 | /**
63 | * Setter for CategoryId.
64 | * @param int $category_id Unique identifier for an existing category.
65 | * @return SearchCategory
66 | * @throws StockApiException if category id is negative.
67 | */
68 | public function setCategoryId(int $category_id) : SearchCategory
69 | {
70 | if ($category_id < 0) {
71 | throw StockApiException::withMessage('Category Id cannot be negative');
72 | }
73 |
74 | $this->category_id = $category_id;
75 | return $this;
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/src/Request/SearchFiles.php:
--------------------------------------------------------------------------------
1 | locale;
44 | }
45 |
46 | /**
47 | * Setter for Locale.
48 | * @param string $locale Language location code.
49 | * @return SearchFiles
50 | */
51 | public function setLocale(?string $locale = null) : SearchFiles
52 | {
53 | if ($locale == null) {
54 | throw StockApiException::withMessage('Locale cannot be null');
55 | }
56 |
57 | $this->locale = $locale;
58 | return $this;
59 | }
60 |
61 | /**
62 | * Get SearchParameters array that consists of various search params
63 | * @return SearchParametersModel|null
64 | */
65 | public function getSearchParams() : ?SearchParametersModel
66 | {
67 | return $this->search_parameters;
68 | }
69 |
70 | /**
71 | * Sets SearchParameters object that consists of various search params
72 | * @param SearchParametersModel $search_parameters
73 | * @return SearchFiles
74 | */
75 | public function setSearchParams(?SearchParametersModel $search_parameters = null) : SearchFiles
76 | {
77 | if ($search_parameters == null) {
78 | throw StockApiException::withMessage('SearchParams array cannot be null');
79 | }
80 |
81 | $this->search_parameters = $search_parameters;
82 | return $this;
83 | }
84 |
85 | /**
86 | * Get ResultColumns array that you have included for columns
87 | * @return array|null
88 | */
89 | public function getResultColumns() : ?array
90 | {
91 | return $this->result_columns;
92 | }
93 |
94 | /**
95 | * Set ResultColumns array consisting of result column constants
96 | * @param array $result_columns
97 | * @return SearchFiles
98 | */
99 | public function setResultColumns(?array $result_columns = null) : SearchFiles
100 | {
101 | if (empty($result_columns)) {
102 | throw StockApiException::withMessage('ResultColumns array cannot be empty');
103 | }
104 |
105 | $this->result_columns = $result_columns;
106 | return $this;
107 | }
108 |
109 | /**
110 | * Getter for similar image path.
111 | * @return string|null Similar image path.
112 | */
113 | public function getSimilarImage() : ?string
114 | {
115 | return $this->similar_image;
116 | }
117 |
118 | /**
119 | * Setter for similar image path.
120 | * @param string $similar_image Similar Image Path.
121 | * @return SearchFiles
122 | */
123 | public function setSimilarImage(string $similar_image) : SearchFiles
124 | {
125 | if (!file_exists($similar_image)) {
126 | throw StockApiException::withMessage('Image File doesn\'t exist on this path');
127 | }
128 |
129 | $this->similar_image = $similar_image;
130 | return $this;
131 | }
132 | }
133 |
--------------------------------------------------------------------------------
/src/Response/Files.php:
--------------------------------------------------------------------------------
1 | nb_results = null;
31 | $this->files = [];
32 | }
33 |
34 | /**
35 | * InitializeResponse function for Files
36 | * @param array $raw_response Array contains value of various keys of Files Class
37 | */
38 | public function initializeResponse(array $raw_response) : void
39 | {
40 | foreach ($raw_response as $key => $val) {
41 | if (property_exists($this, $key)) {
42 | if (is_array($val) && $key == 'files') {
43 | $result_array_objects = [];
44 | foreach ($val as $element) {
45 | $result_array_objects[] = new StockFile($element);
46 | }
47 | $this->files = $result_array_objects;
48 | } else {
49 | $this->$key = $val;
50 | }
51 | }
52 | }
53 | }
54 |
55 | /**
56 | * Get total number of found assets in the response.
57 | *
58 | * @return int|null
59 | */
60 | public function getNbResults() : ?int
61 | {
62 | return $this->nb_results;
63 | }
64 |
65 | /**
66 | * Sets total number of found assets in the response.
67 | *
68 | * @param int $nb_results passed value for no of assets
69 | * @return Files
70 | */
71 | public function setNbResults(?int $nb_results = null) : Files
72 | {
73 | $this->nb_results = $nb_results;
74 | return $this;
75 | }
76 |
77 | /**
78 | * Get list of stock media files
79 | *
80 | * @return StockFile[]
81 | */
82 | public function getFiles() : array
83 | {
84 | return $this->files;
85 | }
86 |
87 | /**
88 | * Sets list of stock media files.
89 | *
90 | * @param StockFile[] $files
91 | * @return Files
92 | */
93 | public function setFiles(array $files) : Files
94 | {
95 | $this->files = $files;
96 | return $this;
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/src/Response/LicenseHistory.php:
--------------------------------------------------------------------------------
1 | nb_results = null;
31 | $this->files = [];
32 | }
33 |
34 | /**
35 | * InitializeResponse function for License History
36 | * @param array $raw_response Array contains value of various keys of LicenseHistory Class
37 | */
38 | public function initializeResponse(array $raw_response)
39 | {
40 | foreach ($raw_response as $key => $val) {
41 |
42 | if (property_exists($this, $key)) {
43 |
44 | if (is_array($val) && $key == 'files') {
45 | $result_array_objects = [];
46 |
47 | foreach ($val as $element) {
48 | $stock_file_obj = new StockFileLicenseHistory($element);
49 | $result_array_objects[] = $stock_file_obj;
50 | }
51 |
52 | $this->files = $result_array_objects;
53 | } else {
54 | $this->$key = $val;
55 | }
56 | }
57 | }
58 | }
59 |
60 |
61 | /**
62 | * Get total number of found assets in the search results.
63 | * @return int|null
64 | */
65 | public function getNbResults() : ?int
66 | {
67 | return $this->nb_results;
68 | }
69 |
70 | /**
71 | * Sets total number of found assets in the search results.
72 | * @param int $nb_results passed value for no of assets
73 | * @return LicenseHistory
74 | */
75 | public function setNbResults(?int $nb_results = null) : LicenseHistory
76 | {
77 | $this->nb_results = $nb_results;
78 | return $this;
79 | }
80 |
81 | /**
82 | * Get list of stock media files
83 | * @return array
84 | */
85 | public function getFiles() : array
86 | {
87 | return $this->files;
88 | }
89 |
90 | /**
91 | * Sets list of stock media files.
92 | * @param array $files
93 | * @return LicenseHistory
94 | */
95 | public function setFiles(array $files) : LicenseHistory
96 | {
97 | $this->files = $files;
98 | return $this;
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/src/Response/SearchCategory.php:
--------------------------------------------------------------------------------
1 | $val) {
38 | if (property_exists($this, $key)) {
39 | $this->$key = $val;
40 | }
41 | }
42 | }
43 |
44 | /**
45 | * Getter for Category id.
46 | * @return int
47 | */
48 | public function getId() : int
49 | {
50 | return $this->id;
51 | }
52 |
53 | /**
54 | * Setter for Unique identifier for an existing category.
55 | * @param int $id passed value for category id
56 | * @return SearchCategory response object.
57 | */
58 | public function setId(int $id) : SearchCategory
59 | {
60 | $this->id = $id;
61 | return $this;
62 | }
63 |
64 | /**
65 | * Getter for category name.
66 | * @return string category name
67 | */
68 | public function getName() : string
69 | {
70 | return $this->name;
71 | }
72 |
73 | /**
74 | * Setter for category name.
75 | * @param string $name category name
76 | * @return SearchCategory response object.
77 | */
78 | public function setName(string $name) : SearchCategory
79 | {
80 | $this->name = $name;
81 | return $this;
82 | }
83 |
84 | /**
85 | * Getter for category link.
86 | * @return string
87 | */
88 | public function getLink() : string
89 | {
90 | return $this->link;
91 | }
92 |
93 | /**
94 | * Setter for category Link.
95 | * @param string $link category link
96 | * @return SearchCategory response object.
97 | */
98 | public function setLink(string $link) : SearchCategory
99 | {
100 | $this->link = $link;
101 | return $this;
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/src/Response/SearchFiles.php:
--------------------------------------------------------------------------------
1 | nb_results = null;
31 | $this->files = [];
32 | }
33 |
34 | /**
35 | * InitializeResponse function for SearchFiles
36 | * @param array $raw_response Array contains value of various keys of SearchFiles Class
37 | */
38 | public function initializeResponse(array $raw_response)
39 | {
40 | foreach ($raw_response as $key => $val) {
41 |
42 | if (property_exists($this, $key)) {
43 |
44 | if (is_array($val) && $key == 'files') {
45 | $result_array_objects = [];
46 |
47 | foreach ($val as $element) {
48 | $stock_file_obj = new StockFile($element);
49 | $result_array_objects[] = $stock_file_obj;
50 | }
51 |
52 | $this->files = $result_array_objects;
53 | } else {
54 | $this->$key = $val;
55 | }
56 | }
57 | }
58 | }
59 |
60 | /**
61 | * Get total number of found assets in the search results.
62 | * @return int|null
63 | */
64 | public function getNbResults()
65 | {
66 | $value = $this->nb_results;
67 | return $value;
68 | }
69 |
70 | /**
71 | * Sets total number of found assets in the search results.
72 | * @param int $nb_results passed value for no of assets
73 | * @return SearchFiles
74 | */
75 | public function setNbResults(?int $nb_results = null)
76 | {
77 | $this->nb_results = $nb_results;
78 | return $this;
79 | }
80 |
81 | /**
82 | * Get list of stock media files
83 | * @return array
84 | */
85 | public function getFiles() : array
86 | {
87 | return $this->files;
88 | }
89 |
90 | /**
91 | * Sets list of stock media files.
92 | * @param array $files
93 | * @return SearchFiles
94 | */
95 | public function setFiles(array $files)
96 | {
97 | $this->files = $files;
98 | return $this;
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/test/Helper/BaseTest.php:
--------------------------------------------------------------------------------
1 | getMockBuilder(GuzzleHttpClientInterface::class)
26 | ->disableOriginalConstructor()
27 | ->setMethods([
28 | 'getConfig',
29 | 'request',
30 | 'requestAsync',
31 | 'send',
32 | 'sendAsync',
33 | ])
34 | ->getMock();
35 | }
36 |
37 | /**
38 | * Returns a mock of the GuzzleResponseInterface
39 | *
40 | * @return ResponseInterface
41 | */
42 | public function getGuzzleResponseInterfaceMock() : ResponseInterface
43 | {
44 | return $this->getMockBuilder(ResponseInterface::class)
45 | ->disableOriginalConstructor()
46 | ->setMethods([
47 | 'getStatusCode',
48 | 'withStatus',
49 | 'getReasonPhrase',
50 | 'getProtocolVersion',
51 | 'withProtocolVersion',
52 | 'getHeaders',
53 | 'hasHeader',
54 | 'getHeader',
55 | 'getHeaderLine',
56 | 'withHeader',
57 | 'withAddedHeader',
58 | 'withoutHeader',
59 | 'getBody',
60 | 'withBody',
61 | ])
62 | ->getMock();
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/test/bootstrap.php:
--------------------------------------------------------------------------------
1 | assertEquals('APIKey', $headers['headers']['x-api-key']);
26 | }
27 |
28 | /**
29 | * @param string $absolute_path
30 | * @param StockApi|null $expected_exception
31 | * @dataProvider downSampleImageProvider
32 | */
33 | public function testDownSampleImage(string $absolute_path, StockApi $expected_exception = null): void
34 | {
35 | if ($expected_exception) {
36 | $this->expectExceptionObject($expected_exception);
37 | }
38 |
39 | list($width, $height) = getimagesize($absolute_path);
40 | $image_string = APIUtils::downSampleImage($absolute_path);
41 |
42 | $image = imagecreatefromstring($image_string);
43 | $result_width = imagesx($image);
44 | $result_height = imagesy($image);
45 |
46 | $this->assertLessThanOrEqual(min($width, 1000), $result_width);
47 | $this->assertLessThanOrEqual(min($height, 1000), $result_height);
48 |
49 | $this->assertNotNull($image);
50 | }
51 |
52 | /**
53 | * @return array
54 | */
55 | public function downSampleImageProvider(): array
56 | {
57 | return [
58 | 'width_greater_than_height' => [
59 | $this->_getAbsolutePath('test/resources/TestFileWidth.png'),
60 | ],
61 | 'height_greater_than_width' => [
62 | $this->_getAbsolutePath('test/resources/TestFile.png'),
63 | ],
64 | 'small_image' => [
65 | $this->_getAbsolutePath('test/resources/SmallImage.jpg'),
66 | ],
67 | 'not_supported_image' => [
68 | $this->_getAbsolutePath('test/resources/UnsupportedBMP.bmp'),
69 | new StockApi('Only jpg, png and gifs are supported image formats'),
70 | ],
71 | 'bigger_than_expected_image' => [
72 | $this->_getAbsolutePath('test/resources/BigImage.jpg'),
73 | new StockApi('Image is too large for visual search!'),
74 | ],
75 | ];
76 | }
77 |
78 | /**
79 | * @param string $path_in_project
80 | * @return string
81 | */
82 | private function _getAbsolutePath(string $path_in_project): string
83 | {
84 | return dirname(dirname(dirname(dirname(__DIR__)))) . '/' . $path_in_project;
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/test/src/Api/Client/FilesFactoryTest.php:
--------------------------------------------------------------------------------
1 | _mocked_http_client = $this->createMock(HttpClient::class);
46 | $this->_config = new CoreConfig('APIKey', 'Product', 'STAGE');
47 | $this->_files_factory = new FilesFactory($this->_config);
48 | $this->assertInstanceOf(FilesFactory::class, $this->_files_factory);
49 | }
50 |
51 | /**
52 | * @test
53 | */
54 | public function getFilesShouldReturnValidResponse() : void
55 | {
56 | $requestMock = $this->createMock(FilesRequest::class);
57 | $requestMock->method('toArray')->willReturn([]);
58 | $this->_mocked_http_client->method('doGet')->willReturn(Psr7\Utils::streamFor('{
59 | "nb_results":3,
60 | "files":[{"id":281266321},{"id":285285249},{"id":264874647}]
61 | }'));
62 | $response = $this->_files_factory->getFiles($requestMock, $this->_mocked_http_client, '');
63 | $this->assertEquals(3, $response->getNbResults());
64 | $this->assertTrue(is_array($response->getFiles()));
65 | }
66 |
67 | /**
68 | * @test
69 | */
70 | public function getFilesShouldThrowExceptionWhenAccessTokenIsNullWithIsLicensedColumn() : void
71 | {
72 | $this->expectException(\AdobeStock\Api\Exception\StockApi::class);
73 | $requestMock = $this->createMock(FilesRequest::class);
74 | $requestMock->method('getResultColumns')->willReturn(['is_licensed']);
75 | $this->_files_factory->getFiles($requestMock, $this->_mocked_http_client);
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/test/src/Api/Client/Http/HttpClientTest.php:
--------------------------------------------------------------------------------
1 | _mocked_http_client = $this->createMock(Client::class);
40 | $this->_client = new HttpClient($this->_mocked_http_client);
41 | $this->assertNotNull($this->_client);
42 | }
43 |
44 | /**
45 | * @test
46 | */
47 | public function executeDoGetSuccessfully()
48 | {
49 | $response = new Response(200, [], 'response');
50 | $this->_mocked_http_client->method('request')->willReturn($response);
51 | $this->assertEquals($response->getBody(), $this->_client->doGet('some uri', []));
52 | }
53 |
54 | /**
55 | * @test
56 | */
57 | public function executeDoGetWithException()
58 | {
59 | $this->expectException(\AdobeStock\Api\Exception\StockApi::class);
60 | $exception = StockApiException::withMessage('Exception thrown');
61 | $this->_mocked_http_client->method('request')->will($this->throwException($exception));
62 | $this->_client->doGet('some uri', []);
63 | }
64 |
65 | /**
66 | * @test
67 | */
68 | public function executeDoPostSuccessfully()
69 | {
70 | $response = new Response(200, [], 'response');
71 | $this->_mocked_http_client->method('request')->willReturn($response);
72 | $this->assertEquals($response->getBody(), $this->_client->doPost('some uri', [], []));
73 | }
74 |
75 | /**
76 | * @test
77 | */
78 | public function executeDoPostWithException()
79 | {
80 | $this->expectException(\AdobeStock\Api\Exception\StockApi::class);
81 | $exception = StockApiException::withMessage('Exception thrown');
82 | $this->_mocked_http_client->method('request')->will($this->throwException($exception));
83 | $this->_client->doPost('some uri', [], []);
84 | }
85 |
86 | /**
87 | * @test
88 | */
89 | public function executeDoMultiPartSuccessfully()
90 | {
91 | $response = new Response(200, [], 'response');
92 | $this->_mocked_http_client->method('request')->willReturn($response);
93 | $this->assertEquals($response->getBody(), $this->_client->doMultiPart('some uri', [], 'test/resources/SmallImage.jpg'));
94 | }
95 |
96 | /**
97 | * @test
98 | */
99 | public function executeDoMultiPartWithException()
100 | {
101 | $this->expectException(\AdobeStock\Api\Exception\StockApi::class);
102 | $exception = StockApiException::withMessage('Exception thrown');
103 | $this->_mocked_http_client->method('request')->will($this->throwException($exception));
104 | $this->_client->doMultiPart('some uri', [], 'test/resources/SmallImage.jpg');
105 | }
106 |
107 | /**
108 | * @test
109 | */
110 | public function executeDoMultiPartWithExceptionIfFileIsNotReadable()
111 | {
112 | $this->expectException(\AdobeStock\Api\Exception\StockApi::class);
113 | $exception = StockApiException::withMessage('Exception thrown');
114 | $this->_mocked_http_client->method('request')->will($this->throwException($exception));
115 | $this->_client->doMultiPart('some uri', [], '');
116 | }
117 |
118 | /**
119 | * @test
120 | */
121 | public function testGetHandlerStack()
122 | {
123 | $stack = new HandlerStack();
124 | $this->_mocked_http_client->method('getConfig')->willReturn($stack);
125 | $this->assertEquals($stack, $this->_client->getHandlerStack());
126 | }
127 |
128 | /**
129 | * @test
130 | */
131 | public function testSendRequest()
132 | {
133 | $response = new Response(200, [], '');
134 | $this->_mocked_http_client->method('send')->willReturn($response);
135 | $this->assertEquals($response, $this->_client->sendRequest(new Request('GET', '')));
136 | }
137 | }
138 |
--------------------------------------------------------------------------------
/test/src/Api/Client/SearchCategoryFactoryTest.php:
--------------------------------------------------------------------------------
1 | _mocked_http_client = $this->createMock(HttpClient::class);
51 | $this->_config = new CoreConfig('APIKey', 'Product', 'STAGE');
52 | $this->_search_category_factory = new SearchCategoryFactory($this->_config);
53 | $this->assertInstanceOf(SearchCategoryFactory::class, $this->_search_category_factory);
54 | }
55 |
56 | /**
57 | * @test
58 | */
59 | public function getCategoryShouldReturnValidResponse()
60 | {
61 | $this->_request = new SearchCategoryRequest();
62 | $this->_request->setCategoryId(1043);
63 | $this->_mocked_http_client->method('doGet')->willReturn(Psr7\Utils::streamFor('{
64 | "id": 1043,
65 | "link": "/Category/travel/1043",
66 | "name": "Travel"
67 | }'));
68 | $final_response = $this->_search_category_factory->getCategory($this->_request, '', $this->_mocked_http_client);
69 | $this->assertEquals('Travel', $final_response->getName());
70 | }
71 |
72 | /**
73 | * @test
74 | */
75 | public function getCategoryShouldThrowExceptionIfCategoryIdIsNull()
76 | {
77 | $this->expectException(\AdobeStock\Api\Exception\StockApi::class);
78 | $this->_request = new SearchCategoryRequest();
79 | $this->_mocked_http_client->method('doGet')->willReturn(Psr7\Utils::streamFor('{
80 | "id": 1043,
81 | "link": "/Category/travel/1043",
82 | "name": "Travel"
83 | }'));
84 | $final_response = $this->_search_category_factory->getCategory($this->_request, '', $this->_mocked_http_client);
85 | }
86 |
87 | /**
88 | * @test
89 | */
90 | public function getCategoryTreeShouldThrowExceptionIfCategoryIdIsNull()
91 | {
92 | $this->expectException(\AdobeStock\Api\Exception\StockApi::class);
93 | $this->_request = new SearchCategoryRequest();
94 | $this->_mocked_http_client->method('doGet')->willReturn(Psr7\Utils::streamFor('{
95 | "id": 1043,
96 | "link": "/Category/travel/1043",
97 | "name": "Travel"
98 | }'));
99 | $final_response = $this->_search_category_factory->getCategoryTree($this->_request, '', $this->_mocked_http_client);
100 | }
101 |
102 | /**
103 | * @test
104 | */
105 | public function getCategoryTreeShouldReturnValidResponse()
106 | {
107 | $this->_request = new SearchCategoryRequest();
108 | $this->_request->setCategoryId(1043);
109 | $this->_mocked_http_client->method('doGet')->willReturn(Psr7\Utils::streamFor('[{
110 | "id": 1043,
111 | "link": "/Category/travel/1043",
112 | "name": "Travel"
113 | }]'));
114 | $final_response = $this->_search_category_factory->getCategoryTree($this->_request, '', $this->_mocked_http_client);
115 | $this->assertEquals('Travel', $final_response[0]->getName());
116 | }
117 | }
118 |
--------------------------------------------------------------------------------
/test/src/Api/Core/ConfigTest.php:
--------------------------------------------------------------------------------
1 | _config = new CoreConfig('APIKey', 'Product', 'PROD');
29 | $this->assertInstanceOf(CoreConfig::class, $this->_config);
30 | $this->_config = new CoreConfig('APIKey', 'Product', 'STAGE');
31 | $this->assertEquals('STAGE', $this->_config->getTargetEnv());
32 | }
33 |
34 | /**
35 | * @test
36 | */
37 | public function setterGetterShouldSetGetApikey()
38 | {
39 | $this->_config->setApiKey('key');
40 | $this->assertEquals('key', $this->_config->getApiKey());
41 | }
42 |
43 | /**
44 | * @test
45 | */
46 | public function setterGetterShouldSetGetProduct()
47 | {
48 | $this->_config->setProduct('product');
49 | $this->assertEquals('product', $this->_config->getProduct());
50 | }
51 |
52 | /**
53 | * @test
54 | */
55 | public function setterGetterShouldSetGetTargetEnv()
56 | {
57 | $this->_config->setTargetEnv('STAG');
58 | $this->assertEquals('STAG', $this->_config->getTargetEnv());
59 | }
60 |
61 | /**
62 | * @test
63 | */
64 | public function setterGetterShouldSetGetEndPoints()
65 | {
66 | $end_points = [
67 | 'endPoint',
68 | ];
69 | $this->_config->setEndPoints($end_points);
70 | $this->assertEquals('endPoint', $this->_config->getEndPoints()[0]);
71 | }
72 |
73 | /**
74 | * @test
75 | */
76 | public function isConfigInitializedShouldReturnFalseSinceEnvIsFalse()
77 | {
78 | $this->assertTrue($this->_config->isConfigInitialized());
79 | $this->_config->setTargetEnv('');
80 | $this->assertFalse($this->_config->isConfigInitialized());
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/test/src/Api/Core/ConstantsTest.php:
--------------------------------------------------------------------------------
1 | assertEquals('Standard', $constants['STANDARD']);
23 | }
24 |
25 | /**
26 | * @test
27 | */
28 | public function testGetQueryParamsProps()
29 | {
30 | $constants = CoreConstants::getQueryParamsProps();
31 | $this->assertEquals('locale', $constants['LOCALE']);
32 | }
33 |
34 | /**
35 | * @test
36 | */
37 | public function testGetHttpMethod()
38 | {
39 | $constants = CoreConstants::getHttpMethod();
40 | $this->assertEquals('POST', $constants['POST']);
41 | }
42 |
43 | /**
44 | * @test
45 | */
46 | public function testgetSearchParams3DTypes()
47 | {
48 | $constants = CoreConstants::getSearchParams3DTypes();
49 | $this->assertEquals(1, $constants['MODELS']);
50 | }
51 |
52 | /**
53 | * @test
54 | */
55 | public function testgetSearchParamsType()
56 | {
57 | $constants = CoreConstants::getSearchParamsType();
58 | $this->assertEquals(0, $constants['STRING']);
59 | }
60 |
61 | /**
62 | * @test
63 | */
64 | public function testgetPurchaseStateParams()
65 | {
66 | $constants = CoreConstants::getPurchaseStateParams();
67 | $this->assertEquals('purchased', $constants['PURCHASED']);
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/test/src/Api/Exception/StockApiExceptionTest.php:
--------------------------------------------------------------------------------
1 | assertInstanceOf(StockApiException::class, $stock_exception);
24 | }
25 |
26 | /**
27 | * @test
28 | */
29 | public function withMessageWillReturnInstanceOfStockApiException()
30 | {
31 | $stock_exception = StockApiException::withMessage('hello');
32 | $this->assertInstanceOf(StockApiException::class, $stock_exception);
33 | }
34 |
35 | /**
36 | * @test
37 | */
38 | public function withMessageAndCodeWillReturnInstanceOfStockApiException()
39 | {
40 | $stock_exception = StockApiException::withMessageAndErrorCode('error', 100, new \Exception());
41 | $this->assertInstanceOf(StockApiException::class, $stock_exception);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/test/src/Api/Models/LicenseCompTest.php:
--------------------------------------------------------------------------------
1 | 'http://adobetest.com',
27 | 'content_type' => 'test',
28 | 'width' => 1,
29 | 'heigth' => 1,
30 | 'frame_rate' => 1.2,
31 | 'content_length' => 1,
32 | 'duration' => 1,
33 | ];
34 |
35 | /**
36 | * @test
37 | * @before
38 | */
39 | public function initializeConstructorOfLicenseComp()
40 | {
41 | $this->_license_comp = new LicenseComp($this->_data);
42 | $this->assertInstanceOf(LicenseComp::class, $this->_license_comp);
43 | }
44 |
45 | /**
46 | * @test
47 | */
48 | public function setterGetterShouldSetGetUrl()
49 | {
50 | $this->_license_comp->setUrl('testUrl');
51 | $this->assertEquals('testUrl', $this->_license_comp->getUrl());
52 | }
53 |
54 | /**
55 | * @test
56 | */
57 | public function setterGetterShouldSetGetContentType()
58 | {
59 | $this->_license_comp->setContentType('comp');
60 | $this->assertEquals('comp', $this->_license_comp->getContentType());
61 | }
62 |
63 | /**
64 | * @test
65 | */
66 | public function setterGetterShouldSetGetWidth()
67 | {
68 | $this->_license_comp->setWidth(23);
69 | $this->assertEquals(23, $this->_license_comp->getWidth());
70 | }
71 |
72 | /**
73 | * @test
74 | */
75 | public function setterGetterShouldSetGetHeight()
76 | {
77 | $this->_license_comp->setHeight(23);
78 | $this->assertEquals(23, $this->_license_comp->getHeight());
79 | }
80 |
81 | /**
82 | * @test
83 | */
84 | public function setterGetterShouldSetGetFrameRate()
85 | {
86 | $this->_license_comp->setFrameRate(2.1);
87 | $this->assertEquals(2.1, $this->_license_comp->getFrameRate());
88 | }
89 |
90 | /**
91 | * @test
92 | */
93 | public function setterGetterShouldSetGetContentLength()
94 | {
95 | $this->_license_comp->setContentLength(23);
96 | $this->assertEquals(23, $this->_license_comp->getContentLength());
97 | }
98 |
99 | /**
100 | * @test
101 | */
102 | public function setterGetterShouldSetGetDuration()
103 | {
104 | $this->_license_comp->setDuration(5);
105 | $this->assertEquals(5, $this->_license_comp->getDuration());
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/test/src/Api/Models/LicenseContentTest.php:
--------------------------------------------------------------------------------
1 | 1,
30 | 'purchase_details' => [],
31 | 'size' => 'test',
32 | 'comp' => [],
33 | 'thumbnail' => [],
34 | ];
35 |
36 | /**
37 | * @test
38 | * @before
39 | */
40 | public function initializeConstructorOfLicenseContent()
41 | {
42 | $this->_license_content = new LicenseContent($this->_data);
43 | $this->assertInstanceOf(LicenseContent::class, $this->_license_content);
44 | }
45 |
46 | /**
47 | * @test
48 | */
49 | public function setterGetterShouldSetGetContentId()
50 | {
51 | $this->_license_content->setContentId(123);
52 | $this->assertEquals(123, $this->_license_content->getContentId());
53 | }
54 |
55 | /**
56 | * @test
57 | */
58 | public function setterGetterShouldSetGetSize()
59 | {
60 | $this->expectException(\AdobeStock\Api\Exception\StockApi::class);
61 | $this->_license_content->setSize('Comp');
62 | $this->assertEquals('Comp', $this->_license_content->getSize());
63 | $this->_license_content->setSize('Original');
64 | $this->assertEquals('Original', $this->_license_content->getSize());
65 | $this->_license_content->setSize('Compsss');
66 | }
67 |
68 | /**
69 | * @test
70 | */
71 | public function setterGetterShouldSetGetThumbnail()
72 | {
73 | $thumbnail = new LicenseThumbnail([]);
74 | $thumbnail->setUrl('test');
75 | $this->_license_content->setThumbnail($thumbnail);
76 | $this->assertEquals('test', $this->_license_content->getThumbnail()->getUrl());
77 | }
78 |
79 | /**
80 | * @test
81 | */
82 | public function setterGetterShouldSetGetComp()
83 | {
84 | $thumbnail = new LicenseComp([]);
85 | $thumbnail->setUrl('test');
86 | $this->_license_content->setComp($thumbnail);
87 | $this->assertEquals('test', $this->_license_content->getComp()->getUrl());
88 | }
89 |
90 | /**
91 | * @test
92 | */
93 | public function setterGetterShouldSetGetPurchaseDetails()
94 | {
95 | $thumbnail = new LicensePurchaseDetails([]);
96 | $thumbnail->setUrl('test');
97 | $this->_license_content->setPurchaseDetails($thumbnail);
98 | $this->assertEquals('test', $this->_license_content->getPurchaseDetails()->getUrl());
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/test/src/Api/Models/LicenseEntitlementQuotaTest.php:
--------------------------------------------------------------------------------
1 | 1,
28 | 'video_quota' => 1,
29 | 'credits_quota' => 1,
30 | 'standard_credits_quota' => 1,
31 | 'premium_credits_quota' => 1,
32 | 'universal_credits_quota' => 1,
33 | ];
34 |
35 | /**
36 | * @test
37 | * @before
38 | */
39 | public function initializeConstructorOfLicenseEntitlementQuota()
40 | {
41 | $this->_license_entitlement_quota = new LicenseEntitlementQuota($this->_data);
42 | $this->assertInstanceOf(LicenseEntitlementQuota::class, $this->_license_entitlement_quota);
43 | }
44 |
45 | /**
46 | * @test
47 | */
48 | public function setterGetterShouldSetGetImageQuota()
49 | {
50 | $this->_license_entitlement_quota->setImageQuota(2);
51 | $this->assertEquals(2, $this->_license_entitlement_quota->getImageQuota());
52 | }
53 |
54 | /**
55 | * @test
56 | */
57 | public function setterGetterShouldSetGetVideoQuota()
58 | {
59 | $this->_license_entitlement_quota->setVideoQuota(3);
60 | $this->assertEquals(3, $this->_license_entitlement_quota->getVideoQuota());
61 | }
62 |
63 | /**
64 | * @test
65 | */
66 | public function setterGetterShouldSetGetCreditsQuota()
67 | {
68 | $this->_license_entitlement_quota->setCreditsQuota(23);
69 | $this->assertEquals(23, $this->_license_entitlement_quota->getCreditsQuota());
70 | }
71 |
72 | /**
73 | * @test
74 | */
75 | public function setterGetterShouldSetGetStandardCreditQuota()
76 | {
77 | $this->_license_entitlement_quota->setStandardCreditQuota(23);
78 | $this->assertEquals(23, $this->_license_entitlement_quota->getStandardCreditQuota());
79 | }
80 |
81 | /**
82 | * @test
83 | */
84 | public function setterGetterShouldSetGetPremiumCreditsQuota()
85 | {
86 | $this->_license_entitlement_quota->setPremiumCreditsQuota(23);
87 | $this->assertEquals(23, $this->_license_entitlement_quota->getPremiumCreditsQuota());
88 | }
89 |
90 | /**
91 | * @test
92 | */
93 | public function setterGetterShouldSetGetUniversalCreditsQuota()
94 | {
95 | $this->_license_entitlement_quota->setUniversalCreditsQuota(23);
96 | $this->assertEquals(23, $this->_license_entitlement_quota->getUniversalCreditsQuota());
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/test/src/Api/Models/LicenseEntitlementTest.php:
--------------------------------------------------------------------------------
1 | 1,
28 | 'license_type_id' => 2,
29 | 'has_credit_model' => true,
30 | 'has_agency_model' => false,
31 | 'is_cce' => true,
32 | 'full_entitlement_quota' => [],
33 | ];
34 |
35 | /**
36 | * @test
37 | * @before
38 | */
39 | public function initializeConstructorOfLicenseEntitlement()
40 | {
41 | $this->_license_entitlement = new LicenseEntitlement($this->_data);
42 | $this->assertInstanceOf(LicenseEntitlement::class, $this->_license_entitlement);
43 | }
44 |
45 | /**
46 | * @test
47 | */
48 | public function setterGetterShouldSetGetQuota()
49 | {
50 | $this->_license_entitlement->setQuota(3);
51 | $this->assertEquals(3, $this->_license_entitlement->getQuota());
52 | }
53 |
54 | /**
55 | * @test
56 | */
57 | public function setterGetterShouldSetGetLicenseTypeId()
58 | {
59 | $this->_license_entitlement->setLicenseTypeId(123);
60 | $this->assertEquals(123, $this->_license_entitlement->getLicenseTypeId());
61 | }
62 |
63 | /**
64 | * @test
65 | */
66 | public function setterGetterShouldSetGetHasCreditModel()
67 | {
68 | $this->_license_entitlement->setHasCreditModel(true);
69 | $this->assertEquals(true, $this->_license_entitlement->getHasCreditModel());
70 | }
71 |
72 | /**
73 | * @test
74 | */
75 | public function setterGetterShouldSetGetHasAgencyModel()
76 | {
77 | $this->_license_entitlement->setHasAgencyModel(true);
78 | $this->assertEquals(true, $this->_license_entitlement->getHasAgencyModel());
79 | }
80 |
81 | /**
82 | * @test
83 | */
84 | public function setterGetterShouldSetGetIsCce()
85 | {
86 | $this->_license_entitlement->setIsCce(false);
87 | $this->assertEquals(false, $this->_license_entitlement->getIsCce());
88 | }
89 |
90 | /**
91 | * @test
92 | */
93 | public function setterGetterShouldSetGetFullEntitlementQuota()
94 | {
95 | $quota = new LicenseEntitlementQuota([]);
96 | $quota->setCreditsQuota(5);
97 | $this->_license_entitlement->setFullEntitlementQuota($quota);
98 | $this->assertEquals(5, $this->_license_entitlement->getFullEntitlementQuota()->getCreditsQuota());
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/test/src/Api/Models/LicenseMemberInfoTest.php:
--------------------------------------------------------------------------------
1 | 1,
27 | ];
28 |
29 | /**
30 | * @test
31 | * @before
32 | */
33 | public function initializeConstructorOfLicenseMemberInfo()
34 | {
35 | $this->_license_member_info = new LicenseMemberInfo($this->_data);
36 | $this->assertInstanceOf(LicenseMemberInfo::class, $this->_license_member_info);
37 | }
38 |
39 | /**
40 | * @test
41 | */
42 | public function setterGetterShouldSetGetStockId()
43 | {
44 | $this->_license_member_info->setStockId(1234);
45 | $this->assertEquals(1234, $this->_license_member_info->getStockId());
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/test/src/Api/Models/LicensePurchaseOptionsTest.php:
--------------------------------------------------------------------------------
1 | 'test',
27 | 'requires_checkout' => true,
28 | 'message' => 'test',
29 | 'url' => 'http://adobetest.com',
30 | ];
31 |
32 | /**
33 | * @test
34 | * @before
35 | */
36 | public function initializeConstructorOfLicensePurchaseOptions()
37 | {
38 | $this->_license_purchase_options = new LicensePurchaseOptions($this->_data);
39 | $this->assertInstanceOf(LicensePurchaseOptions::class, $this->_license_purchase_options);
40 | }
41 |
42 | /**
43 | * @test
44 | */
45 | public function setterGetterShouldSetGetState()
46 | {
47 | $this->expectException(\AdobeStock\Api\Exception\StockApi::class);
48 | $this->_license_purchase_options->setPurchaseState('NOT_PURCHASED');
49 | $this->assertEquals('not_purchased', $this->_license_purchase_options->getPurchaseState());
50 | $this->_license_purchase_options->setPurchaseState('TEST');
51 | }
52 |
53 | /**
54 | * @test
55 | */
56 | public function setterGetterShouldSetGetRequiresCheckout()
57 | {
58 | $this->_license_purchase_options->setRequiresCheckout(true);
59 | $this->assertEquals(true, $this->_license_purchase_options->getRequiresCheckout());
60 | }
61 |
62 | /**
63 | * @test
64 | */
65 | public function setterGetterShouldSetGetMessage()
66 | {
67 | $this->_license_purchase_options->setMessage('Stock');
68 | $this->assertEquals('Stock', $this->_license_purchase_options->getMessage());
69 | }
70 |
71 | /**
72 | * @test
73 | */
74 | public function setterGetterShouldSetGetPurchaseUrl()
75 | {
76 | $this->_license_purchase_options->setPurchaseUrl('http');
77 | $this->assertEquals('http', $this->_license_purchase_options->getPurchaseUrl());
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/test/src/Api/Models/LicenseReferenceResponseTest.php:
--------------------------------------------------------------------------------
1 | 1,
27 | 'text' => 'test',
28 | 'required' => true,
29 | ];
30 |
31 | /**
32 | * @test
33 | * @before
34 | */
35 | public function initializeConstructorOfLicenseReferenceResponse()
36 | {
37 | $this->_license_reference_response = new LicenseReferenceResponse($this->_data);
38 | $this->assertInstanceOf(LicenseReferenceResponse::class, $this->_license_reference_response);
39 | }
40 |
41 | /**
42 | * @test
43 | */
44 | public function setterGetterShouldSetGetLicenseReferenceId()
45 | {
46 | $this->_license_reference_response->setLicenseReferenceId(1234);
47 | $this->assertEquals(1234, $this->_license_reference_response->getLicenseReferenceId());
48 | }
49 |
50 | /**
51 | * @test
52 | */
53 | public function setterGetterShouldSetGetRequired()
54 | {
55 | $this->_license_reference_response->setRequired(true);
56 | $this->assertEquals(true, $this->_license_reference_response->getRequired());
57 | }
58 |
59 | /**
60 | * @test
61 | */
62 | public function setterGetterShouldSetGetText()
63 | {
64 | $this->_license_reference_response->setText('test');
65 | $this->assertEquals('test', $this->_license_reference_response->getText());
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/test/src/Api/Models/LicenseReferenceTest.php:
--------------------------------------------------------------------------------
1 | 1,
27 | 'value' => 'test',
28 | ];
29 |
30 | /**
31 | * @test
32 | * @before
33 | */
34 | public function initializeConstructorOfLicenseReference()
35 | {
36 | $this->_license_reference = new LicenseReference($this->_data);
37 | $this->assertInstanceOf(LicenseReference::class, $this->_license_reference);
38 | }
39 |
40 | /**
41 | * @test
42 | */
43 | public function setterGetterShouldSetGetLicenseReferenceId()
44 | {
45 | $this->expectException(\AdobeStock\Api\Exception\StockApi::class);
46 | $this->_license_reference->setLicenseReferenceId(1234);
47 | $this->assertEquals(1234, $this->_license_reference->getLicenseReferenceId());
48 | $this->_license_reference->setLicenseReferenceId(-1);
49 | }
50 |
51 | /**
52 | * @test
53 | */
54 | public function setterGetterShouldSetGetLicenseReferenceValue()
55 | {
56 | $this->expectException(\AdobeStock\Api\Exception\StockApi::class);
57 | $this->_license_reference->setLicenseReferenceValue('test2');
58 | $this->assertEquals('test2', $this->_license_reference->getLicenseReferenceValue());
59 | $this->_license_reference->setLicenseReferenceValue('');
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/test/src/Api/Models/LicenseThumbnailTest.php:
--------------------------------------------------------------------------------
1 | 'test',
27 | 'content_type' => 'image',
28 | 'width' => 1,
29 | 'height' => 5,
30 | ];
31 |
32 | /**
33 | * @test
34 | * @before
35 | */
36 | public function initializeConstructorOfLicenseThumbnail()
37 | {
38 | $this->_license_thumbnail = new LicenseThumbnail($this->_data);
39 | $this->assertInstanceOf(LicenseThumbnail::class, $this->_license_thumbnail);
40 | }
41 |
42 | /**
43 | * @test
44 | */
45 | public function setterGetterShouldSetGetUrl()
46 | {
47 | $this->_license_thumbnail->setUrl('testUrl');
48 | $this->assertEquals('testUrl', $this->_license_thumbnail->getUrl());
49 | }
50 |
51 | /**
52 | * @test
53 | */
54 | public function setterGetterShouldSetGetContentType()
55 | {
56 | $this->_license_thumbnail->setContentType('comp');
57 | $this->assertEquals('comp', $this->_license_thumbnail->getContentType());
58 | }
59 |
60 | /**
61 | * @test
62 | */
63 | public function setterGetterShouldSetGetWidth()
64 | {
65 | $this->_license_thumbnail->setWidth(23);
66 | $this->assertEquals(23, $this->_license_thumbnail->getWidth());
67 | }
68 |
69 | /**
70 | * @test
71 | */
72 | public function setterGetterShouldSetGetHeight()
73 | {
74 | $this->_license_thumbnail->setHeight(23);
75 | $this->assertEquals(23, $this->_license_thumbnail->getHeight());
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/test/src/Api/Models/SearchParamLicenseHistoryTest.php:
--------------------------------------------------------------------------------
1 | search_params_license_history = new SearchParamLicenseHistoryModel();
27 | $this->assertInstanceOf(SearchParamLicenseHistoryModel::class, $this->search_params_license_history);
28 | }
29 |
30 | /**
31 | * @test
32 | */
33 | public function testLimit()
34 | {
35 | $this->expectException(\AdobeStock\Api\Exception\StockApi::class);
36 | $this->expectExceptionMessage('Limit should be greater than 0');
37 | $this->search_params_license_history->setLimit(50);
38 | $this->assertEquals(50, $this->search_params_license_history->getLimit());
39 | $this->search_params_license_history->setLimit(-1);
40 | }
41 |
42 | /**
43 | * @test
44 | */
45 | public function testOffset()
46 | {
47 | $this->expectException(\AdobeStock\Api\Exception\StockApi::class);
48 | $this->expectExceptionMessage('Offset should be greater than 0');
49 | $this->search_params_license_history->setOffset(100);
50 | $this->assertEquals(100, $this->search_params_license_history->getOffset());
51 | $this->search_params_license_history->setOffset(-1);
52 | }
53 |
54 | /**
55 | * @test
56 | */
57 | public function testThumbnailSize()
58 | {
59 | $this->expectException(\AdobeStock\Api\Exception\StockApi::class);
60 | $this->expectExceptionMessage('Invalid Thumbnail size');
61 | $this->search_params_license_history->setThumbnailSize(110);
62 | $this->assertEquals(110, $this->search_params_license_history->getThumbnailSize());
63 | $this->search_params_license_history->setThumbnailSize(100);
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/test/src/Api/Models/StockFileCompPropTest.php:
--------------------------------------------------------------------------------
1 | 100,
22 | 'height' => 200,
23 | 'url' => 'http://adobetest.com',
24 | ];
25 |
26 | /**
27 | * StockFileCompPropModelsTest class object
28 | * @var StockFileCompPropModels
29 | */
30 | private $_stock_file_comp_prop_object;
31 |
32 | /**
33 | * @test
34 | * @before
35 | */
36 | public function initializeConstructorOfStockFileCompPropModels()
37 | {
38 | $this->_stock_file_comp_prop_object = new StockFileCompPropModels($this->_stock_file_comp_prop_data);
39 | $this->assertInstanceOf(StockFileCompPropModels::class, $this->_stock_file_comp_prop_object);
40 | }
41 |
42 | /**
43 | * @test
44 | */
45 | public function testAllTheGettersSettersReturnandSetTheProperValue()
46 | {
47 | $this->_stock_file_comp_prop_object->setWidth(101);
48 | $this->assertEquals(101, $this->_stock_file_comp_prop_object->getWidth());
49 | $this->_stock_file_comp_prop_object->setHeight(201);
50 | $this->assertEquals(201, $this->_stock_file_comp_prop_object->getHeight());
51 | $this->_stock_file_comp_prop_object->setUrl('http://adobetest2.com');
52 | $this->assertEquals('http://adobetest2.com', $this->_stock_file_comp_prop_object->getUrl());
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/test/src/Api/Models/StockFileCompsTest.php:
--------------------------------------------------------------------------------
1 | 100,
23 | 'height' => 200,
24 | 'url' => 'http://adobetest.com',
25 | ];
26 |
27 | /**
28 | * StockFileCompPropModelsTest class object
29 | * @var StockFileCompPropModels
30 | */
31 | private $_stock_file_comp_prop_object;
32 |
33 | /**
34 | * StockFileLicenses class object
35 | * @var StockFileCompsModels
36 | */
37 | private $_stock_file_comps_object;
38 |
39 | /**
40 | * @test
41 | * @before
42 | */
43 | public function initializeConstructorOfStockFileComps()
44 | {
45 | $this->_stock_file_comp_prop_object = new StockFileCompPropModels($this->_stock_file_comps_prop_data);
46 | $_stock_file_comps_data = [
47 | 'Standard' => $this->_stock_file_comp_prop_object,
48 | ];
49 | $this->_stock_file_comps_object = new StockFileCompsModels($_stock_file_comps_data);
50 | $this->assertInstanceOf(StockFileCompsModels::class, $this->_stock_file_comps_object);
51 | }
52 |
53 | /**
54 | * @test
55 | */
56 | public function testAllTheGettersSettersReturnandSetTheProperValue()
57 | {
58 | $comp_models = [
59 | 'width' => 100,
60 | ];
61 | $_stock_file_comp_prop_object = new StockFileCompPropModels($comp_models);
62 | $this->_stock_file_comps_object->setStandard($_stock_file_comp_prop_object);
63 | $this->assertEquals($_stock_file_comp_prop_object, $this->_stock_file_comps_object->getStandard());
64 |
65 | $this->_stock_file_comps_object->setVideoHD($_stock_file_comp_prop_object);
66 | $this->assertEquals($_stock_file_comp_prop_object, $this->_stock_file_comps_object->getVideoHD());
67 |
68 | $this->_stock_file_comps_object->setVideo4K($_stock_file_comp_prop_object);
69 | $this->assertEquals($_stock_file_comp_prop_object, $this->_stock_file_comps_object->getVideo4K());
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/test/src/Api/Models/StockFileKeywordTest.php:
--------------------------------------------------------------------------------
1 | 'hello',
22 | ];
23 |
24 | /**
25 | * StockFileKeywordTest class object
26 | * @var StockFileKeyword
27 | */
28 | private $_stock_file_keyword_object;
29 |
30 | /**
31 | * @test
32 | * @before
33 | */
34 | public function initializeConstructorOfStockFileKeyword()
35 | {
36 | $this->_stock_file_keyword_object = new StockFileKeyword($this->_stock_file_keyword_data);
37 | $this->assertInstanceOf(StockFileKeyword::class, $this->_stock_file_keyword_object);
38 | }
39 |
40 | /**
41 | * @test
42 | */
43 | public function testAllTheGettersSettersReturnandSetTheProperValue()
44 | {
45 | $this->_stock_file_keyword_object->setName('helloWorld');
46 | $this->assertEquals('helloWorld', $this->_stock_file_keyword_object->getName());
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/test/src/Api/Models/StockFileLicensePropTest.php:
--------------------------------------------------------------------------------
1 | 100,
22 | 'height' => 200,
23 | 'url' => 'http://adobetest.com',
24 | ];
25 |
26 | /**
27 | * StockFileLicensePropModelsTest class object
28 | * @var StockFileLicensePropModels
29 | */
30 | private $_stock_file_license_prop_object;
31 |
32 | /**
33 | * @test
34 | * @before
35 | */
36 | public function initializeConstructorOfStockFileLicensePropModels()
37 | {
38 | $this->_stock_file_license_prop_object = new StockFileLicensePropModels($this->_stock_file_license_prop_data);
39 | $this->assertInstanceOf(StockFileLicensePropModels::class, $this->_stock_file_license_prop_object);
40 | }
41 |
42 | /**
43 | * @test
44 | */
45 | public function testAllTheGettersSettersReturnandSetTheProperValue()
46 | {
47 | $this->_stock_file_license_prop_object->setWidth(101);
48 | $this->assertEquals(101, $this->_stock_file_license_prop_object->getWidth());
49 | $this->_stock_file_license_prop_object->setHeight(201);
50 | $this->assertEquals(201, $this->_stock_file_license_prop_object->getHeight());
51 | $this->_stock_file_license_prop_object->setUrl('http://adobetest2.com');
52 | $this->assertEquals('http://adobetest2.com', $this->_stock_file_license_prop_object->getUrl());
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/test/src/Api/Models/StockFileLicensesTest.php:
--------------------------------------------------------------------------------
1 | 100,
23 | 'height' => 200,
24 | 'url' => 'http://adobetest.com',
25 | ];
26 |
27 | /**
28 | * StockFileLicensePropModelsTest class object
29 | * @var StockFileLicensePropModels
30 | */
31 | private $_stock_file_license_prop_object;
32 |
33 | /**
34 | * StockFileLicensesModels class object
35 | * @var StockFileLicensesModels
36 | */
37 | private $_stock_file_licenses_object;
38 |
39 | /**
40 | * @test
41 | * @before
42 | */
43 | public function initializeConstructorOfStockFileLicensesModels()
44 | {
45 | $this->_stock_file_license_prop_object = new StockFileLicensePropModels($this->_stock_file_license_prop_data);
46 | $object = [
47 | 'Standard' => $this->_stock_file_license_prop_object,
48 | 'Standard_M' => $this->_stock_file_license_prop_object,
49 | ];
50 | $this->_stock_file_licenses_object = new StockFileLicensesModels($object);
51 | $this->assertInstanceOf(StockFileLicensesModels::class, $this->_stock_file_licenses_object);
52 | }
53 |
54 | /**
55 | * @test
56 | */
57 | public function testAllTheGettersSettersReturnandSetTheProperValue()
58 | {
59 | $this->_stock_file_license_prop_object = new StockFileLicensePropModels($this->_stock_file_license_prop_data);
60 | $this->_stock_file_licenses_object->setStandard($this->_stock_file_license_prop_object);
61 | $this->assertInstanceOf(StockFileLicensePropModels::class, $this->_stock_file_licenses_object->getStandard());
62 | $this->_stock_file_licenses_object->setStandardM($this->_stock_file_license_prop_object);
63 | $this->assertInstanceOf(StockFileLicensePropModels::class, $this->_stock_file_licenses_object->getStandardM());
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/test/src/Api/Request/FilesRequestTest.php:
--------------------------------------------------------------------------------
1 | _request = new FilesRequest();
31 | $this->assertInstanceOf(FilesRequest::class, $this->_request);
32 | }
33 |
34 | /**
35 | * @test
36 | */
37 | public function testAllTheGettersSettersReturnandSetTheProperValue() : void
38 | {
39 | $result_column_array = [
40 | 'nb_results',
41 | 'country_name',
42 | 'id',
43 | ];
44 | $this->_request->setIds([1, 2, 3]);
45 | $this->assertEquals([1, 2, 3], $this->_request->getIds());
46 | $this->_request->setLocale('En-US');
47 | $this->assertEquals('En-US', $this->_request->getLocale());
48 | $this->_request->setResultColumns($result_column_array);
49 | $this->assertEquals($result_column_array, $this->_request->getResultColumns());
50 | }
51 |
52 | /**
53 | * @test
54 | */
55 | public function testToArrayReturnsValidArray() : void
56 | {
57 | $result_column_array = [
58 | 'nb_results',
59 | 'country_name',
60 | 'id',
61 | ];
62 | $this->_request->setIds([1, 2, 3]);
63 | $this->_request->setLocale('En-US');
64 | $this->_request->setResultColumns($result_column_array);
65 | $this->assertEquals([
66 | Constants::getQueryParamsProps()['IDS'] => '1,2,3',
67 | Constants::getQueryParamsProps()['LOCALE'] => 'En-US',
68 | Constants::getQueryParamsProps()['RESULT_COLUMNS'] => $result_column_array
69 | ], $this->_request->toArray());
70 | }
71 |
72 |
73 |
74 | /**
75 | * @test
76 | */
77 | public function setIdsThrowException()
78 | {
79 | $this->expectException(\TypeError::class);
80 | $this->_request->setIds(null);
81 | }
82 |
83 | /**
84 | * @test
85 | */
86 | public function setLocaleThrowException()
87 | {
88 | $this->expectException(\TypeError::class);
89 | $this->_request->setLocale(null);
90 | }
91 |
92 | /**
93 | * @test
94 | */
95 | public function setResultColumnsThrowException()
96 | {
97 | $this->expectException(\TypeError::class);
98 | $this->_request->setResultColumns(null);
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/test/src/Api/Request/LicenseHistoryRequestTest.php:
--------------------------------------------------------------------------------
1 | _request = new LicenseHistoryRequest();
30 | $this->assertInstanceOf(LicenseHistoryRequest::class, $this->_request);
31 | }
32 |
33 | /**
34 | * @test
35 | */
36 | public function testAllTheGettersSettersReturnandSetTheProperValue()
37 | {
38 | $search_params_license_history = new SearchParamLicenseHistoryModel();
39 | $search_params_license_history->setLimit(3)->setOffset(0);
40 |
41 | $result_column_array = [
42 | 'THUMBNAIL_110_URL',
43 | 'THUMBNAIL_110_WIDTH',
44 | ];
45 |
46 | $this->_request->setLocale('En-US');
47 | $this->assertEquals('En-US', $this->_request->getLocale());
48 | $this->_request->setSearchParams($search_params_license_history);
49 | $this->assertInstanceOf(SearchParamLicenseHistoryModel::class, $this->_request->getSearchParams());
50 | $this->_request->setResultColumns($result_column_array);
51 | $this->assertEquals($result_column_array, $this->_request->getResultColumns());
52 | }
53 |
54 | /**
55 | * @test
56 | */
57 | public function setSearchParamsThrowException()
58 | {
59 | $this->expectException(\AdobeStock\Api\Exception\StockApi::class);
60 | $this->_request->setSearchParams(null);
61 | }
62 |
63 | /**
64 | * @test
65 | */
66 | public function setLocaleThrowException()
67 | {
68 | $this->expectException(\AdobeStock\Api\Exception\StockApi::class);
69 | $this->_request->setLocale(null);
70 | }
71 |
72 | /**
73 | * @test
74 | */
75 | public function setResultColumnsThrowException()
76 | {
77 | $this->expectException(\AdobeStock\Api\Exception\StockApi::class);
78 | $this->_request->setResultColumns([]);
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/test/src/Api/Request/LicenseRequestTest.php:
--------------------------------------------------------------------------------
1 | _request = new LicenseRequest();
30 | $this->assertInstanceOf(LicenseRequest::class, $this->_request);
31 | }
32 |
33 | /**
34 | * @test
35 | */
36 | public function setterGetterShouldSetGetContentId()
37 | {
38 | $this->_request->setContentId(10431);
39 | $this->assertEquals(10431, $this->_request->getContentId());
40 | }
41 |
42 | /**
43 | * @test
44 | */
45 | public function setterGetterShouldSetGetLocale()
46 | {
47 | $this->expectException(\AdobeStock\Api\Exception\StockApi::class);
48 | $this->_request->setLocale('En-US');
49 | $this->assertEquals('En-US', $this->_request->getLocale());
50 | $this->_request->setLocale('');
51 | }
52 |
53 | /**
54 | * @test
55 | */
56 | public function setContentIdShouldThrowExceptionIfNegativeValueIsPassed()
57 | {
58 | $this->expectException(\AdobeStock\Api\Exception\StockApi::class);
59 | $this->_request->setContentId(-1);
60 | }
61 |
62 | /**
63 | * @test
64 | */
65 | public function setterGetterShouldSetGetLicenseState()
66 | {
67 | $this->expectException(\AdobeStock\Api\Exception\StockApi::class);
68 | $this->_request->setLicenseState('STANDARD');
69 | $this->assertEquals('Standard', $this->_request->getLicenseState());
70 | $this->_request->setLicenseState('');
71 | }
72 |
73 | /**
74 | * @test
75 | */
76 | public function setterGetterShouldSetGetPurchaseState()
77 | {
78 | $this->expectException(\AdobeStock\Api\Exception\StockApi::class);
79 | $this->_request->setPurchaseState('NOT_PURCHASED');
80 | $this->assertEquals('not_purchased', $this->_request->getPurchaseState());
81 | $this->_request->setPurchaseState('');
82 | }
83 |
84 | /**
85 | * @test
86 | */
87 | public function setterGetterShouldSetGetFormat()
88 | {
89 | $this->assertEquals(false, $this->_request->getFormat());
90 | $this->_request->setFormat(true);
91 | $this->assertEquals(true, $this->_request->getFormat());
92 | }
93 |
94 | /**
95 | * @test
96 | */
97 | public function setterGetterShouldSetGetLicenseReference()
98 | {
99 | $this->expectException(\AdobeStock\Api\Exception\StockApi::class);
100 | $data = [
101 | ['id' => 1,
102 | 'value' => 'test',
103 | ],
104 | ];
105 | $this->_request->setLicenseReference($data);
106 | $this->assertEquals(1, $this->_request->getLicenseReference()[0]->getLicenseReferenceId());
107 | $this->_request->setLicenseReference([]);
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/test/src/Api/Request/SearchCategoryRequestTest.php:
--------------------------------------------------------------------------------
1 | _request = new SearchCategoryRequest();
32 | $this->assertInstanceOf(SearchCategoryRequest::class, $this->_request);
33 | }
34 |
35 | /**
36 | * @test
37 | */
38 | public function setterGetterShouldSetGetCategoryId()
39 | {
40 | $this->_request->setCategoryId(1043);
41 | $this->assertEquals(1043, $this->_request->getCategoryId());
42 | }
43 |
44 | /**
45 | * @test
46 | */
47 | public function setterGetterShouldSetGetLocale()
48 | {
49 | $this->expectException(\AdobeStock\Api\Exception\StockApi::class);
50 | $this->_request->setLocale('En-US');
51 | $this->assertEquals('En-US', $this->_request->getLocale());
52 | $this->_request->setLocale('');
53 | }
54 |
55 | /**
56 | * @test
57 | */
58 | public function setCategoryIdShouldThrowExceptionIfNegativeValueIsPassed()
59 | {
60 | $this->expectException(\AdobeStock\Api\Exception\StockApi::class);
61 | $this->_request->setCategoryId(-1);
62 | }
63 |
64 | /**
65 | * @test
66 | */
67 | public function generateCommonAPIHeadersShouldGenerateHeadersArrayFromConfigAndAccessToken()
68 | {
69 | $config = new CoreConfig('APIKey', 'Product', 'STAGE');
70 | $headers = APIUtils::generateCommonAPIHeaders($config, '');
71 | $this->assertEquals('APIKey', $headers['headers']['x-api-key']);
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/test/src/Api/Request/SearchFilesRequestTest.php:
--------------------------------------------------------------------------------
1 | _request = new SearchFilesRequest();
30 | $this->assertInstanceOf(SearchFilesRequest::class, $this->_request);
31 | }
32 |
33 | /**
34 | * @test
35 | */
36 | public function testAllTheGettersSettersReturnandSetTheProperValue()
37 | {
38 | $search_params = new SearchParametersModels();
39 | $search_params->setWords('tree')->setLimit(3)->setOffset(0);
40 |
41 | $result_column_array = [
42 | 'nb_results',
43 | 'country_name',
44 | 'id',
45 | ];
46 |
47 | $this->_request->setLocale('En-US');
48 | $this->assertEquals('En-US', $this->_request->getLocale());
49 | $this->_request->setSearchParams($search_params);
50 | $this->assertInstanceOf(SearchParametersModels::class, $this->_request->getSearchParams());
51 | $this->_request->setResultColumns($result_column_array);
52 | $this->assertEquals($result_column_array, $this->_request->getResultColumns());
53 | $this->_request->setSimilarImage('test/resources/TestFile.png');
54 | }
55 |
56 | /**
57 | * @test
58 | */
59 | public function setSearchParamsThrowException()
60 | {
61 | $this->expectException(\AdobeStock\Api\Exception\StockApi::class);
62 | $this->_request->setSearchParams(null);
63 | }
64 |
65 | /**
66 | * @test
67 | */
68 | public function setLocaleThrowException()
69 | {
70 | $this->expectException(\AdobeStock\Api\Exception\StockApi::class);
71 | $this->_request->setLocale(null);
72 | }
73 |
74 | /**
75 | * @test
76 | */
77 | public function setResultColumnsThrowException()
78 | {
79 | $this->expectException(\AdobeStock\Api\Exception\StockApi::class);
80 | $this->_request->setResultColumns([]);
81 | }
82 |
83 | /**
84 | * @test
85 | */
86 | public function setSimilarImageThrowExceptionIfFileDoesntExist()
87 | {
88 | $this->expectException(\AdobeStock\Api\Exception\StockApi::class);
89 | $this->_request->setSimilarImage('');
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/test/src/Api/Response/FilesResponseTest.php:
--------------------------------------------------------------------------------
1 | _response = new FilesResponse();
30 | $this->assertInstanceOf(FilesResponse::class, $this->_response);
31 | }
32 | /**
33 | * @test
34 | */
35 | public function testAllTheGettersSettersReturnandSetTheProperValue() : void
36 | {
37 | $this->_response->setNbResults(5);
38 | $this->assertEquals(5, $this->_response->getNbResults());
39 |
40 | $this->_response->setFiles([]);
41 | $this->assertEquals([], $this->_response->getFiles());
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/test/src/Api/Response/LicenseHistoryResponseTest.php:
--------------------------------------------------------------------------------
1 | _response = new LicenseHistoryResponse();
28 | $this->assertInstanceOf(LicenseHistoryResponse::class, $this->_response);
29 | }
30 | /**
31 | * @test
32 | */
33 | public function testAllTheGettersSettersReturnandSetTheProperValue()
34 | {
35 | $this->_response->setNbResults(5);
36 | $this->assertEquals(5, $this->_response->getNbResults());
37 |
38 | $this->_response->setFiles([]);
39 | $this->assertEquals([], $this->_response->getFiles());
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/test/src/Api/Response/LicenseResponseTest.php:
--------------------------------------------------------------------------------
1 | 103,
33 | ];
34 | $this->_response = new LicenseResponse($data);
35 | $this->assertInstanceOf(LicenseResponse::class, $this->_response);
36 | }
37 |
38 | /**
39 | * @test
40 | */
41 | public function setterGetterShouldSetGetEntitlement()
42 | {
43 | $val = new LicenseEntitlement([]);
44 | $val->setQuota(5);
45 | $this->_response->setEntitlement($val);
46 | $this->assertEquals(5, $this->_response->getEntitlement()->getQuota());
47 | }
48 |
49 | /**
50 | * @test
51 | */
52 | public function setterGetterShouldSetGetPurchaseOptions()
53 | {
54 | $val = new LicensePurchaseOptions([]);
55 | $val->setMessage('stock');
56 | $this->_response->setPurchaseOptions($val);
57 | $this->assertEquals('stock', $this->_response->getPurchaseOptions()->getMessage());
58 | }
59 |
60 | /**
61 | * @test
62 | */
63 | public function setterGetterShouldSetGetMemberInfo()
64 | {
65 | $val = new LicenseMemberInfo([]);
66 | $val->setStockId(123);
67 | $this->_response->setMemberInfo($val);
68 | $this->assertEquals(123, $this->_response->getMemberInfo()->getStockId());
69 | }
70 |
71 | /**
72 | * @test
73 | */
74 | public function setterGetterShouldSetGetCceAgency()
75 | {
76 | $this->_response->setLicenseReference([]);
77 | $this->assertEquals([], $this->_response->getLicenseReference());
78 | }
79 |
80 | /**
81 | * @test
82 | */
83 | public function setterGetterShouldSetGetContents()
84 | {
85 | $data = [
86 | '59741022' => [],
87 | ];
88 | $this->_response->setContents($data);
89 | $this->assertEquals($data, $this->_response->getContents());
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/test/src/Api/Response/SearchCategoryResponseTest.php:
--------------------------------------------------------------------------------
1 | 103,
30 | ];
31 | $this->_response = new SearchCategoryResponse($data);
32 | $this->assertInstanceOf(SearchCategoryResponse::class, $this->_response);
33 | }
34 |
35 | /**
36 | * @test
37 | */
38 | public function setterGetterShouldSetGetCategoryId()
39 | {
40 | $this->_response->setId(1043);
41 | $this->assertEquals(1043, $this->_response->getId());
42 | }
43 |
44 | /**
45 | * @test
46 | */
47 | public function setterGetterShouldSetGetName()
48 | {
49 | $this->_response->setName('Travel');
50 | $this->assertEquals('Travel', $this->_response->getName());
51 | }
52 |
53 | /**
54 | * @test
55 | */
56 | public function setterGetterShouldSetGetLink()
57 | {
58 | $this->_response->setLink('/Category/travel/1043');
59 | $this->assertEquals('/Category/travel/1043', $this->_response->getLink());
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/test/src/Api/Response/SearchFilesResponseTest.php:
--------------------------------------------------------------------------------
1 | _response = new SearchFilesResponse();
28 | $this->assertInstanceOf(SearchFilesResponse::class, $this->_response);
29 | }
30 | /**
31 | * @test
32 | */
33 | public function testAllTheGettersSettersReturnandSetTheProperValue()
34 | {
35 | $this->_response->setNbResults(5);
36 | $this->assertEquals(5, $this->_response->getNbResults());
37 |
38 | $this->_response->setFiles([]);
39 | $this->assertEquals([], $this->_response->getFiles());
40 | }
41 | }
42 |
--------------------------------------------------------------------------------