Skip to content

Commit

Permalink
Fix URL generation (#34)
Browse files Browse the repository at this point in the history
* Fix URL generation

* Remove double 1236

* Fix metafields service
  • Loading branch information
robwittman authored Aug 12, 2019
1 parent 52773d2 commit 25c773f
Show file tree
Hide file tree
Showing 39 changed files with 186 additions and 181 deletions.
2 changes: 1 addition & 1 deletion src/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public function init()
$args = array();
if (!is_null($this->myshopify_domain)) {
$args['base_uri'] = sprintf(
"https://%s/admin/api/%s",
"https://%s/admin/api/%s/",
$this->myshopify_domain,
$this->getApiVersion()
);
Expand Down
5 changes: 5 additions & 0 deletions src/Object/AbstractObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ public function setData($data)
}
}

public function getData()
{
return $this->data;
}

public function castToType($value, $type)
{
if (is_null($value)) {
Expand Down
4 changes: 2 additions & 2 deletions src/Service/AbandonedCheckoutsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class AbandonedCheckoutsService extends AbstractService
*/
public function all(array $params = array())
{
$data = $this->request('/checkouts.json', 'GET', $params);
$data = $this->request('checkouts.json', 'GET', $params);
return $this->createCollection(AbandonedCheckout::class, $data['checkouts']);
}

Expand All @@ -28,7 +28,7 @@ public function all(array $params = array())
*/
public function count(array $params = array())
{
$data = $this->request('/checkouts/count.json', 'GET', $params);
$data = $this->request('checkouts/count.json', 'GET', $params);
return $data['count'];
}
}
8 changes: 4 additions & 4 deletions src/Service/ApplicationChargeService.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ApplicationChargeService extends AbstractService
*/
public function all(array $params = array())
{
$data = $this->request('/application_charges.json', 'GET', $params);
$data = $this->request('application_charges.json', 'GET', $params);
return $this->createCollection(ApplicationCharge::class, $data['application_charges']);
}

Expand All @@ -33,7 +33,7 @@ public function get($applicationChargeId, array $fields = array())
if (!empty($fields)) {
$params['fields'] = implode(',', $fields);
}
$data = $this->request('/application_charges/'.$applicationChargeId.'.json', 'GET', $params);
$data = $this->request('application_charges/'.$applicationChargeId.'.json', 'GET', $params);
return $this->createObject(ApplicationCharge::class, $data['application_charge']);
}

Expand All @@ -47,7 +47,7 @@ public function get($applicationChargeId, array $fields = array())
public function create(ApplicationCharge &$applicationCharge)
{
$data = $applicationCharge->exportData();
$endpoint = '/admin/application_charges.json';
$endpoint = 'application_charges.json';
$response = $this->request(
$endpoint, 'POST', array(
'application_charge' => $data
Expand All @@ -65,7 +65,7 @@ public function create(ApplicationCharge &$applicationCharge)
*/
public function activate(ApplicationCharge &$applicationCharge)
{
$response = $this->request('/admin/application_charges/'.$applicationCharge->id.'/activate.json', 'POST');
$response = $this->request('application_charges/'.$applicationCharge->id.'/activate.json', 'POST');
$applicationCharge->setData($response['application_charge']);
}
}
6 changes: 3 additions & 3 deletions src/Service/ApplicationCreditService.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ApplicationCreditService extends AbstractService
*/
public function all(array $params = array())
{
$data = $this->request('/application_credits.json', 'GET', $params);
$data = $this->request('application_credits.json', 'GET', $params);
return $this->createCollection(ApplicationCredit::class, $data['application_credits']);
}

Expand All @@ -33,7 +33,7 @@ public function get($applicationCreditId, array $fields = array())
if (!empty($fields)) {
$params['fields'] = implode(',', $fields);
}
$endpoint = '/application_credits/'.$applicationCreditId.'.json';
$endpoint = 'application_credits/'.$applicationCreditId.'.json';
$data = $this->request($endpoint, 'GET', $params);
return $this->createObject(ApplicationCredit::class, $data['application_credit']);
}
Expand All @@ -48,7 +48,7 @@ public function get($applicationCreditId, array $fields = array())
public function create(ApplicationCredit &$applicationCredit)
{
$data = $applicationCredit->exportData();
$endpoint = '/application_credits.json';
$endpoint = 'application_credits.json';
$response = $this->request(
$endpoint, 'POST', array(
'application_charge' => $data
Expand Down
16 changes: 8 additions & 8 deletions src/Service/ArticleService.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ArticleService extends AbstractService
*/
public function all($blogId, array $params = array())
{
$endpoint = '/blogs/'.$blogId.'/articles.json';
$endpoint = 'blogs/'.$blogId.'/articles.json';
$data = $this->request($endpoint, 'GET', $params);
return $this->createCollection(Article::class, $data['articles']);
}
Expand All @@ -31,7 +31,7 @@ public function all($blogId, array $params = array())
*/
public function count($blogId, array $params = array())
{
$endpoint = '/blogs/'.$blogId.'/articles/count.json';
$endpoint = 'blogs/'.$blogId.'/articles/count.json';
$response = $this->request($endpoint, 'GET', $params);
return $response['count'];
}
Expand All @@ -51,7 +51,7 @@ public function get($blogId, $articleId, array $fields = array())
if (!empty($fields)) {
$params['fields'] = implode(',', $fields);
}
$endpoint = '/blogs/'.$blogId.'/articles/'.$articleId.'.json';
$endpoint = 'blogs/'.$blogId.'/articles/'.$articleId.'.json';
$response = $this->request($endpoint, 'GET', $params);
return $this->createObject(Article::class, $response['article']);
}
Expand All @@ -67,7 +67,7 @@ public function get($blogId, $articleId, array $fields = array())
public function create($blogId, Article &$article)
{
$data = $article->exportData();
$endpoint = '/blogs/'.$blogId.'/articles.json';
$endpoint = 'blogs/'.$blogId.'/articles.json';
$response = $this->request(
$endpoint, 'POST', array(
'article' => $data
Expand All @@ -87,7 +87,7 @@ public function create($blogId, Article &$article)
public function update($blogId, Article &$article)
{
$data = $article->exportData();
$endpoint = '/blogs/'.$blogId.'/articles/'.$article->id.'.json';
$endpoint = 'blogs/'.$blogId.'/articles/'.$article->id.'.json';
$response = $this->request(
$endpoint, 'POST', array(
'article' => $data
Expand All @@ -107,7 +107,7 @@ public function update($blogId, Article &$article)
public function delete($blogId, Article &$article)
{
$articleId = $article->getId();
$endpoint = '/blogs/'.$blogId.'/articles/'.$articleId.'.json';
$endpoint = 'blogs/'.$blogId.'/articles/'.$articleId.'.json';
$this->request($endpoint, 'DELETE');
}

Expand All @@ -119,7 +119,7 @@ public function delete($blogId, Article &$article)
*/
public function authors()
{
$endpoint = '/articles/authors.json';
$endpoint = 'articles/authors.json';
$response = $this->request($endpoint, 'GET');
return $response['authors'];
}
Expand All @@ -132,7 +132,7 @@ public function authors()
*/
public function tags()
{
$endpoint = '/articles/tags.json';
$endpoint = 'articles/tags.json';
$response = $this->request($endpoint, 'GET');
return $response['tags'];
}
Expand Down
8 changes: 4 additions & 4 deletions src/Service/BlogService.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class BlogService extends AbstractService
*/
public function all(array $params = array())
{
$endpoint = '/blogs.json';
$endpoint = 'blogs.json';
$response = $this->request($endpoint, 'GET', $params);
return $this->createCollection(Blog::class, $response['blogs']);
}
Expand All @@ -29,7 +29,7 @@ public function all(array $params = array())
*/
public function count()
{
$endpoint = '/blogs/count.json';
$endpoint = 'blogs/count.json';
$response = $this->request($endpoint, 'GET');
return $response['count'];
}
Expand All @@ -48,7 +48,7 @@ public function get($blogId, array $fields = array())
if (!empty($fields)) {
$params['fields'] = implode(',', $fields);
}
$endpoint = '/blogs/'.$blogId.'.json';
$endpoint = 'blogs/'.$blogId.'.json';
$response = $this->request($endpoint, 'GET', $params);
return $this->createObject(Blog::class, $response['blog']);
}
Expand All @@ -63,7 +63,7 @@ public function get($blogId, array $fields = array())
public function create(Blog &$blog)
{
$data = $blog->exportData();
$endpoint = '/blogs.json';
$endpoint = 'blogs.json';
$response = $this->request(
$endpoint, 'POST', array(
'blog' => $data
Expand Down
10 changes: 5 additions & 5 deletions src/Service/CollectService.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class CollectService extends AbstractService
*/
public function all(array $params = array())
{
$endpoint = '/collects.json';
$endpoint = 'collects.json';
$data = $this->request($endpoint, 'GET', $params);
return $this->createCollection(Collect::class, $data['collects']);
}
Expand All @@ -29,7 +29,7 @@ public function all(array $params = array())
*/
public function count(array $params = array())
{
$endpoint = '/collects/count.json';
$endpoint = 'collects/count.json';
$data = $this->request($endpoint, $params);
return $data['count'];
}
Expand All @@ -48,7 +48,7 @@ public function get($collectId, array $fields = array())
if (!empty($fields)) {
$params['fields'] = implode(',', $fields);
}
$endpoint = '/collects/'.$collectId.'.json';
$endpoint = 'collects/'.$collectId.'.json';
$response = $this->request($endpoint, 'GET', $params);
return $this->createObject(Collect::class, $response['collect']);
}
Expand All @@ -63,7 +63,7 @@ public function get($collectId, array $fields = array())
public function create(Collect &$collect)
{
$data = $collect->exportData();
$endpoint = '/collects.json';
$endpoint = 'collects.json';
$response = $this->request(
$endpoint, 'POST', array(
'collect' => $data
Expand All @@ -81,7 +81,7 @@ public function create(Collect &$collect)
*/
public function delete(Collect &$collect)
{
$endpoint = '/collects/'.$collect->getId().'.json';
$endpoint = 'collects/'.$collect->getId().'.json';
$this->request($endpoint, 'DELETE');
return;
}
Expand Down
20 changes: 10 additions & 10 deletions src/Service/CommentService.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class CommentService extends AbstractService
*/
public function all(array $params = [])
{
$endpoint = '/comments.json';
$endpoint = 'comments.json';
$response = $this->request($endpoint, 'GET', $params);
return $this->createCollection(Comment::class, $response['comments']);
}
Expand All @@ -29,7 +29,7 @@ public function all(array $params = [])
*/
public function count(array $params = [])
{
$endpoint = '/comments/count.json';
$endpoint = 'comments/count.json';
$response = $this->request($endpoint, 'GET', $params);
return $response['count'];
}
Expand All @@ -44,7 +44,7 @@ public function count(array $params = [])
*/
public function get($commentId, array $params = [])
{
$endpoint = '/comments/'.$commentId.'.json';
$endpoint = 'comments/'.$commentId.'.json';
$response = $this->request($endpoint, 'GET', $params);
return $this->createObject(Comment::class, $response['comment']);
}
Expand All @@ -59,7 +59,7 @@ public function get($commentId, array $params = [])
public function create(Comment &$comment)
{
$data = $comment->exportData();
$endpoint = '/comments.json';
$endpoint = 'comments.json';
$response = $this->request(
$endpoint, 'POST', array(
'comment' => $data
Expand All @@ -78,7 +78,7 @@ public function create(Comment &$comment)
public function update(Comment &$comment)
{
$data = $comment->exportData();
$endpoint = '/comments/'.$comment->id.'.json';
$endpoint = 'comments/'.$comment->id.'.json';
$response = $this->request(
$endpoint, 'PUT', array(
'comment' => $data
Expand All @@ -96,7 +96,7 @@ public function update(Comment &$comment)
*/
public function spam(Comment &$comment)
{
$endpoint = '/comments/'.$comment->id.'/spam.json';
$endpoint = 'comments/'.$comment->id.'/spam.json';
$response = $this->request($endpoint, 'POST');
$comment->setData($response['comment']);
}
Expand All @@ -110,7 +110,7 @@ public function spam(Comment &$comment)
*/
public function notSpam(Comment &$comment)
{
$endpoint = '/comments/'.$comment->id.'/not_spam.json';
$endpoint = 'comments/'.$comment->id.'/not_spam.json';
$response = $this->request($endpoint, 'POST');
$comment->setData($response['comment']);
}
Expand All @@ -124,7 +124,7 @@ public function notSpam(Comment &$comment)
*/
public function approve(Comment &$comment)
{
$endpoint = '/comments/'.$comment->id.'/approve.json';
$endpoint = 'comments/'.$comment->id.'/approve.json';
$response = $this->request($endpoint, 'POST');
$comment->setData($response['comment']);
}
Expand All @@ -138,7 +138,7 @@ public function approve(Comment &$comment)
*/
public function remove(Comment &$comment)
{
$endpoint = '/comments/'.$comment->id.'remove.json';
$endpoint = 'comments/'.$comment->id.'remove.json';
$response = $this->request($endpoint, 'POST');
$comment->setData($response['comment']);
}
Expand All @@ -152,7 +152,7 @@ public function remove(Comment &$comment)
*/
public function restore(Comment &$comment)
{
$endpoint = '/comments/'.$comment->id.'/restore.json';
$endpoint = 'comments/'.$comment->id.'/restore.json';
$response = $this->request($endpoint, 'POST');
$comment->setData($response['comment']);
}
Expand Down
12 changes: 6 additions & 6 deletions src/Service/CountryService.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class CountryService extends AbstractService
*/
public function all(array $params = [])
{
$endpoint = '/countries.json';
$endpoint = 'countries.json';
$response = $this->request($endpoint, 'GET', $params);
return $this->createCollection(Country::class, $response['countries']);
}
Expand All @@ -28,7 +28,7 @@ public function all(array $params = [])
*/
public function count()
{
$endpoint = '/countries/count.json';
$endpoint = 'countries/count.json';
$response = $this->request($endpoint, 'GET');
return $response['count'];
}
Expand All @@ -47,7 +47,7 @@ public function get($countryId, array $fields = [])
if (!empty($fields)) {
$params['fields'] = implode(',', $fields);
}
$endpoint = '/countries/'.$countryId.'.json';
$endpoint = 'countries/'.$countryId.'.json';
$response = $this->request($endpoint, 'GET', $params);
return $this->createObject(Country::class, $response['country']);
}
Expand All @@ -62,7 +62,7 @@ public function get($countryId, array $fields = [])
public function create(Country &$country)
{
$data = $country->exportData();
$endpoint = '/countries.json';
$endpoint = 'countries.json';
$response = $this->request(
$endpoint, 'POST', array(
'country' => $data
Expand All @@ -81,7 +81,7 @@ public function create(Country &$country)
public function update(Country &$country)
{
$data = $country->exportData();
$endpoint = '/countries/'.$country->id.'.json';
$endpoint = 'countries/'.$country->id.'.json';
$response = $this->request(
$endpoint, 'PUT', array(
'country' => $data
Expand All @@ -99,7 +99,7 @@ public function update(Country &$country)
*/
public function delete(Country $country)
{
$this->request('/countries/'.$country->id.'.json', 'DELETE');
$this->request('countries/'.$country->id.'.json', 'DELETE');
return;
}
}
Loading

0 comments on commit 25c773f

Please sign in to comment.