Skip to content

Commit 25c773f

Browse files
authored
Fix URL generation (#34)
* Fix URL generation * Remove double 1236 * Fix metafields service
1 parent 52773d2 commit 25c773f

39 files changed

+186
-181
lines changed

src/Api.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public function init()
124124
$args = array();
125125
if (!is_null($this->myshopify_domain)) {
126126
$args['base_uri'] = sprintf(
127-
"https://%s/admin/api/%s",
127+
"https://%s/admin/api/%s/",
128128
$this->myshopify_domain,
129129
$this->getApiVersion()
130130
);

src/Object/AbstractObject.php

+5
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@ public function setData($data)
110110
}
111111
}
112112

113+
public function getData()
114+
{
115+
return $this->data;
116+
}
117+
113118
public function castToType($value, $type)
114119
{
115120
if (is_null($value)) {

src/Service/AbandonedCheckoutsService.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class AbandonedCheckoutsService extends AbstractService
1515
*/
1616
public function all(array $params = array())
1717
{
18-
$data = $this->request('/checkouts.json', 'GET', $params);
18+
$data = $this->request('checkouts.json', 'GET', $params);
1919
return $this->createCollection(AbandonedCheckout::class, $data['checkouts']);
2020
}
2121

@@ -28,7 +28,7 @@ public function all(array $params = array())
2828
*/
2929
public function count(array $params = array())
3030
{
31-
$data = $this->request('/checkouts/count.json', 'GET', $params);
31+
$data = $this->request('checkouts/count.json', 'GET', $params);
3232
return $data['count'];
3333
}
3434
}

src/Service/ApplicationChargeService.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class ApplicationChargeService extends AbstractService
1515
*/
1616
public function all(array $params = array())
1717
{
18-
$data = $this->request('/application_charges.json', 'GET', $params);
18+
$data = $this->request('application_charges.json', 'GET', $params);
1919
return $this->createCollection(ApplicationCharge::class, $data['application_charges']);
2020
}
2121

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

@@ -47,7 +47,7 @@ public function get($applicationChargeId, array $fields = array())
4747
public function create(ApplicationCharge &$applicationCharge)
4848
{
4949
$data = $applicationCharge->exportData();
50-
$endpoint = '/admin/application_charges.json';
50+
$endpoint = 'application_charges.json';
5151
$response = $this->request(
5252
$endpoint, 'POST', array(
5353
'application_charge' => $data
@@ -65,7 +65,7 @@ public function create(ApplicationCharge &$applicationCharge)
6565
*/
6666
public function activate(ApplicationCharge &$applicationCharge)
6767
{
68-
$response = $this->request('/admin/application_charges/'.$applicationCharge->id.'/activate.json', 'POST');
68+
$response = $this->request('application_charges/'.$applicationCharge->id.'/activate.json', 'POST');
6969
$applicationCharge->setData($response['application_charge']);
7070
}
7171
}

src/Service/ApplicationCreditService.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class ApplicationCreditService extends AbstractService
1515
*/
1616
public function all(array $params = array())
1717
{
18-
$data = $this->request('/application_credits.json', 'GET', $params);
18+
$data = $this->request('application_credits.json', 'GET', $params);
1919
return $this->createCollection(ApplicationCredit::class, $data['application_credits']);
2020
}
2121

@@ -33,7 +33,7 @@ public function get($applicationCreditId, array $fields = array())
3333
if (!empty($fields)) {
3434
$params['fields'] = implode(',', $fields);
3535
}
36-
$endpoint = '/application_credits/'.$applicationCreditId.'.json';
36+
$endpoint = 'application_credits/'.$applicationCreditId.'.json';
3737
$data = $this->request($endpoint, 'GET', $params);
3838
return $this->createObject(ApplicationCredit::class, $data['application_credit']);
3939
}
@@ -48,7 +48,7 @@ public function get($applicationCreditId, array $fields = array())
4848
public function create(ApplicationCredit &$applicationCredit)
4949
{
5050
$data = $applicationCredit->exportData();
51-
$endpoint = '/application_credits.json';
51+
$endpoint = 'application_credits.json';
5252
$response = $this->request(
5353
$endpoint, 'POST', array(
5454
'application_charge' => $data

src/Service/ArticleService.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class ArticleService extends AbstractService
1616
*/
1717
public function all($blogId, array $params = array())
1818
{
19-
$endpoint = '/blogs/'.$blogId.'/articles.json';
19+
$endpoint = 'blogs/'.$blogId.'/articles.json';
2020
$data = $this->request($endpoint, 'GET', $params);
2121
return $this->createCollection(Article::class, $data['articles']);
2222
}
@@ -31,7 +31,7 @@ public function all($blogId, array $params = array())
3131
*/
3232
public function count($blogId, array $params = array())
3333
{
34-
$endpoint = '/blogs/'.$blogId.'/articles/count.json';
34+
$endpoint = 'blogs/'.$blogId.'/articles/count.json';
3535
$response = $this->request($endpoint, 'GET', $params);
3636
return $response['count'];
3737
}
@@ -51,7 +51,7 @@ public function get($blogId, $articleId, array $fields = array())
5151
if (!empty($fields)) {
5252
$params['fields'] = implode(',', $fields);
5353
}
54-
$endpoint = '/blogs/'.$blogId.'/articles/'.$articleId.'.json';
54+
$endpoint = 'blogs/'.$blogId.'/articles/'.$articleId.'.json';
5555
$response = $this->request($endpoint, 'GET', $params);
5656
return $this->createObject(Article::class, $response['article']);
5757
}
@@ -67,7 +67,7 @@ public function get($blogId, $articleId, array $fields = array())
6767
public function create($blogId, Article &$article)
6868
{
6969
$data = $article->exportData();
70-
$endpoint = '/blogs/'.$blogId.'/articles.json';
70+
$endpoint = 'blogs/'.$blogId.'/articles.json';
7171
$response = $this->request(
7272
$endpoint, 'POST', array(
7373
'article' => $data
@@ -87,7 +87,7 @@ public function create($blogId, Article &$article)
8787
public function update($blogId, Article &$article)
8888
{
8989
$data = $article->exportData();
90-
$endpoint = '/blogs/'.$blogId.'/articles/'.$article->id.'.json';
90+
$endpoint = 'blogs/'.$blogId.'/articles/'.$article->id.'.json';
9191
$response = $this->request(
9292
$endpoint, 'POST', array(
9393
'article' => $data
@@ -107,7 +107,7 @@ public function update($blogId, Article &$article)
107107
public function delete($blogId, Article &$article)
108108
{
109109
$articleId = $article->getId();
110-
$endpoint = '/blogs/'.$blogId.'/articles/'.$articleId.'.json';
110+
$endpoint = 'blogs/'.$blogId.'/articles/'.$articleId.'.json';
111111
$this->request($endpoint, 'DELETE');
112112
}
113113

@@ -119,7 +119,7 @@ public function delete($blogId, Article &$article)
119119
*/
120120
public function authors()
121121
{
122-
$endpoint = '/articles/authors.json';
122+
$endpoint = 'articles/authors.json';
123123
$response = $this->request($endpoint, 'GET');
124124
return $response['authors'];
125125
}
@@ -132,7 +132,7 @@ public function authors()
132132
*/
133133
public function tags()
134134
{
135-
$endpoint = '/articles/tags.json';
135+
$endpoint = 'articles/tags.json';
136136
$response = $this->request($endpoint, 'GET');
137137
return $response['tags'];
138138
}

src/Service/BlogService.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class BlogService extends AbstractService
1616
*/
1717
public function all(array $params = array())
1818
{
19-
$endpoint = '/blogs.json';
19+
$endpoint = 'blogs.json';
2020
$response = $this->request($endpoint, 'GET', $params);
2121
return $this->createCollection(Blog::class, $response['blogs']);
2222
}
@@ -29,7 +29,7 @@ public function all(array $params = array())
2929
*/
3030
public function count()
3131
{
32-
$endpoint = '/blogs/count.json';
32+
$endpoint = 'blogs/count.json';
3333
$response = $this->request($endpoint, 'GET');
3434
return $response['count'];
3535
}
@@ -48,7 +48,7 @@ public function get($blogId, array $fields = array())
4848
if (!empty($fields)) {
4949
$params['fields'] = implode(',', $fields);
5050
}
51-
$endpoint = '/blogs/'.$blogId.'.json';
51+
$endpoint = 'blogs/'.$blogId.'.json';
5252
$response = $this->request($endpoint, 'GET', $params);
5353
return $this->createObject(Blog::class, $response['blog']);
5454
}
@@ -63,7 +63,7 @@ public function get($blogId, array $fields = array())
6363
public function create(Blog &$blog)
6464
{
6565
$data = $blog->exportData();
66-
$endpoint = '/blogs.json';
66+
$endpoint = 'blogs.json';
6767
$response = $this->request(
6868
$endpoint, 'POST', array(
6969
'blog' => $data

src/Service/CollectService.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class CollectService extends AbstractService
1515
*/
1616
public function all(array $params = array())
1717
{
18-
$endpoint = '/collects.json';
18+
$endpoint = 'collects.json';
1919
$data = $this->request($endpoint, 'GET', $params);
2020
return $this->createCollection(Collect::class, $data['collects']);
2121
}
@@ -29,7 +29,7 @@ public function all(array $params = array())
2929
*/
3030
public function count(array $params = array())
3131
{
32-
$endpoint = '/collects/count.json';
32+
$endpoint = 'collects/count.json';
3333
$data = $this->request($endpoint, $params);
3434
return $data['count'];
3535
}
@@ -48,7 +48,7 @@ public function get($collectId, array $fields = array())
4848
if (!empty($fields)) {
4949
$params['fields'] = implode(',', $fields);
5050
}
51-
$endpoint = '/collects/'.$collectId.'.json';
51+
$endpoint = 'collects/'.$collectId.'.json';
5252
$response = $this->request($endpoint, 'GET', $params);
5353
return $this->createObject(Collect::class, $response['collect']);
5454
}
@@ -63,7 +63,7 @@ public function get($collectId, array $fields = array())
6363
public function create(Collect &$collect)
6464
{
6565
$data = $collect->exportData();
66-
$endpoint = '/collects.json';
66+
$endpoint = 'collects.json';
6767
$response = $this->request(
6868
$endpoint, 'POST', array(
6969
'collect' => $data
@@ -81,7 +81,7 @@ public function create(Collect &$collect)
8181
*/
8282
public function delete(Collect &$collect)
8383
{
84-
$endpoint = '/collects/'.$collect->getId().'.json';
84+
$endpoint = 'collects/'.$collect->getId().'.json';
8585
$this->request($endpoint, 'DELETE');
8686
return;
8787
}

src/Service/CommentService.php

+10-10
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class CommentService extends AbstractService
1515
*/
1616
public function all(array $params = [])
1717
{
18-
$endpoint = '/comments.json';
18+
$endpoint = 'comments.json';
1919
$response = $this->request($endpoint, 'GET', $params);
2020
return $this->createCollection(Comment::class, $response['comments']);
2121
}
@@ -29,7 +29,7 @@ public function all(array $params = [])
2929
*/
3030
public function count(array $params = [])
3131
{
32-
$endpoint = '/comments/count.json';
32+
$endpoint = 'comments/count.json';
3333
$response = $this->request($endpoint, 'GET', $params);
3434
return $response['count'];
3535
}
@@ -44,7 +44,7 @@ public function count(array $params = [])
4444
*/
4545
public function get($commentId, array $params = [])
4646
{
47-
$endpoint = '/comments/'.$commentId.'.json';
47+
$endpoint = 'comments/'.$commentId.'.json';
4848
$response = $this->request($endpoint, 'GET', $params);
4949
return $this->createObject(Comment::class, $response['comment']);
5050
}
@@ -59,7 +59,7 @@ public function get($commentId, array $params = [])
5959
public function create(Comment &$comment)
6060
{
6161
$data = $comment->exportData();
62-
$endpoint = '/comments.json';
62+
$endpoint = 'comments.json';
6363
$response = $this->request(
6464
$endpoint, 'POST', array(
6565
'comment' => $data
@@ -78,7 +78,7 @@ public function create(Comment &$comment)
7878
public function update(Comment &$comment)
7979
{
8080
$data = $comment->exportData();
81-
$endpoint = '/comments/'.$comment->id.'.json';
81+
$endpoint = 'comments/'.$comment->id.'.json';
8282
$response = $this->request(
8383
$endpoint, 'PUT', array(
8484
'comment' => $data
@@ -96,7 +96,7 @@ public function update(Comment &$comment)
9696
*/
9797
public function spam(Comment &$comment)
9898
{
99-
$endpoint = '/comments/'.$comment->id.'/spam.json';
99+
$endpoint = 'comments/'.$comment->id.'/spam.json';
100100
$response = $this->request($endpoint, 'POST');
101101
$comment->setData($response['comment']);
102102
}
@@ -110,7 +110,7 @@ public function spam(Comment &$comment)
110110
*/
111111
public function notSpam(Comment &$comment)
112112
{
113-
$endpoint = '/comments/'.$comment->id.'/not_spam.json';
113+
$endpoint = 'comments/'.$comment->id.'/not_spam.json';
114114
$response = $this->request($endpoint, 'POST');
115115
$comment->setData($response['comment']);
116116
}
@@ -124,7 +124,7 @@ public function notSpam(Comment &$comment)
124124
*/
125125
public function approve(Comment &$comment)
126126
{
127-
$endpoint = '/comments/'.$comment->id.'/approve.json';
127+
$endpoint = 'comments/'.$comment->id.'/approve.json';
128128
$response = $this->request($endpoint, 'POST');
129129
$comment->setData($response['comment']);
130130
}
@@ -138,7 +138,7 @@ public function approve(Comment &$comment)
138138
*/
139139
public function remove(Comment &$comment)
140140
{
141-
$endpoint = '/comments/'.$comment->id.'remove.json';
141+
$endpoint = 'comments/'.$comment->id.'remove.json';
142142
$response = $this->request($endpoint, 'POST');
143143
$comment->setData($response['comment']);
144144
}
@@ -152,7 +152,7 @@ public function remove(Comment &$comment)
152152
*/
153153
public function restore(Comment &$comment)
154154
{
155-
$endpoint = '/comments/'.$comment->id.'/restore.json';
155+
$endpoint = 'comments/'.$comment->id.'/restore.json';
156156
$response = $this->request($endpoint, 'POST');
157157
$comment->setData($response['comment']);
158158
}

src/Service/CountryService.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class CountryService extends AbstractService
1515
*/
1616
public function all(array $params = [])
1717
{
18-
$endpoint = '/countries.json';
18+
$endpoint = 'countries.json';
1919
$response = $this->request($endpoint, 'GET', $params);
2020
return $this->createCollection(Country::class, $response['countries']);
2121
}
@@ -28,7 +28,7 @@ public function all(array $params = [])
2828
*/
2929
public function count()
3030
{
31-
$endpoint = '/countries/count.json';
31+
$endpoint = 'countries/count.json';
3232
$response = $this->request($endpoint, 'GET');
3333
return $response['count'];
3434
}
@@ -47,7 +47,7 @@ public function get($countryId, array $fields = [])
4747
if (!empty($fields)) {
4848
$params['fields'] = implode(',', $fields);
4949
}
50-
$endpoint = '/countries/'.$countryId.'.json';
50+
$endpoint = 'countries/'.$countryId.'.json';
5151
$response = $this->request($endpoint, 'GET', $params);
5252
return $this->createObject(Country::class, $response['country']);
5353
}
@@ -62,7 +62,7 @@ public function get($countryId, array $fields = [])
6262
public function create(Country &$country)
6363
{
6464
$data = $country->exportData();
65-
$endpoint = '/countries.json';
65+
$endpoint = 'countries.json';
6666
$response = $this->request(
6767
$endpoint, 'POST', array(
6868
'country' => $data
@@ -81,7 +81,7 @@ public function create(Country &$country)
8181
public function update(Country &$country)
8282
{
8383
$data = $country->exportData();
84-
$endpoint = '/countries/'.$country->id.'.json';
84+
$endpoint = 'countries/'.$country->id.'.json';
8585
$response = $this->request(
8686
$endpoint, 'PUT', array(
8787
'country' => $data
@@ -99,7 +99,7 @@ public function update(Country &$country)
9999
*/
100100
public function delete(Country $country)
101101
{
102-
$this->request('/countries/'.$country->id.'.json', 'DELETE');
102+
$this->request('countries/'.$country->id.'.json', 'DELETE');
103103
return;
104104
}
105105
}

0 commit comments

Comments
 (0)