Skip to content

Commit 087ecaf

Browse files
Merge pull request #11 from contentstack/region
Region Support
2 parents 87363b8 + c0ffda9 commit 087ecaf

File tree

14 files changed

+27
-4
lines changed

14 files changed

+27
-4
lines changed

.gitignore

100644100755
File mode changed.

LICENSE.txt

100644100755
File mode changed.

config.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?php
2+
3+
return new Sami\Sami('/Users/uttamukkoji/Documents/php/contentstack-php/src');
4+

src/config/index.php

100644100755
File mode changed.

src/contentstackregion.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
/*
3+
* Dependency loading
4+
* */
5+
6+
class ContentstackRegion {
7+
const EU= "eu";
8+
const US= "us";
9+
}

src/lib/models/assets.php

100644100755
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,5 @@ public function fetch() {
6363
$this->operation = __FUNCTION__;
6464
return \Contentstack\Utility\contentstackRequest($this, 'asset');
6565
}
66-
67-
6866
}
6967

src/lib/models/csexception.php

100644100755
File mode changed.

src/lib/models/stack.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,12 @@ class Stack {
2727
/*
2828
* Constructor of the Stack
2929
* */
30-
public function __construct($api_key = '', $access_token = '', $environment = '') {
31-
$this->header = Utility\validateInput('stack', array('api_key' => $api_key, 'access_token' => $access_token, 'environment' => $environment));
30+
public function __construct($api_key = '', $access_token = '', $environment = '', $region = '') {
31+
32+
if($region && $region =="eu" && $region !== "undefined") {
33+
$this->host = $region.'-'.HOST;
34+
}
35+
$this->header = Utility\validateInput('stack', array('api_key' => $api_key, 'access_token' => $access_token, 'environment' => $environment, 'region' => $region));
3236
$this->environment = $this->header['environment'];
3337
unset($this->header['environment']);
3438
return $this;

src/lib/utility.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,16 @@ function validateInput($type = '', $input = array()) {
2222
try {
2323
switch ($type) {
2424
case 'stack' :
25+
if($input['region']) {
26+
if(!(isKeySet($input,'api_key') && isKeySet($input, 'access_token') && isKeySet($input, 'environment') && isKeySet($input, 'region')))
27+
$msg = 'Please provide valid api_key, access_token, environment and region';
28+
break;
29+
} else {
2530
if(!(isKeySet($input,'api_key') && isKeySet($input, 'access_token') && isKeySet($input, 'environment')))
2631
$msg = 'Please provide valid api_key, access_token and environment';
2732
break;
33+
}
34+
2835
case 'port' :
2936
if(isEmpty($input) || !is_numeric($input))
3037
$msg = 'Please provide valid string for '.$type;

test/AssetsTest.php

100644100755
File mode changed.

0 commit comments

Comments
 (0)