Skip to content

Commit f0200a3

Browse files
committed
Merge pull request #4 from LogansUA/feature-diablo-api
Feature diablo api
2 parents 9829eb3 + 27d14ab commit f0200a3

File tree

4 files changed

+147
-5
lines changed

4 files changed

+147
-5
lines changed

README.md

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ API client for Blizzard API written in PHP. [Blizzard API Documentation](https:/
1111

1212
## Installation
1313
### Method 1
14-
```PHP
14+
```
1515
php composer.phar require logansua/blizzard-api-client
1616
```
1717
This command requires you to have Composer installed globally, as explained
@@ -21,7 +21,13 @@ in the [Composer documentation](https://getcomposer.org/doc/00-intro.md).
2121
git clone https://github.com/LogansUA/blizzard-api-client.git
2222
```
2323

24+
## List of available API services
25+
* World of Warcraft
26+
* Diablo 3
27+
2428
## Example
29+
* World of Warcraft
30+
2531
```PHP
2632
require_once __DIR__.'/../vendor/autoload.php';
2733

@@ -45,9 +51,26 @@ var_dump($response->getHeaders());
4551
// Show response body
4652
echo $response->getBody();
4753
```
54+
* Diablo 3
4855

49-
## List of available API services
50-
* World of Warcraft
56+
```PHP
57+
require_once __DIR__.'/../vendor/autoload.php';
58+
59+
$client = new \BlizzardApi\BlizzardClient('apiKey', 'locale', 'region');
60+
61+
$diablo = new \BlizzardApi\Service\Diablo($client);
62+
63+
$response = $diablo->getItemDataById('Unique_Shoulder_103_x1');
64+
65+
// Show status code
66+
var_dump($response->getStatusCode());
67+
68+
// Show headers
69+
var_dump($response->getHeaders());
70+
71+
// Show response body
72+
echo $response->getBody();
73+
```
5174

5275
## License
5376
This software is published under the [MIT License](https://github.com/LogansUA/blizzard-api-client/blob/master/LICENSE)

examples/DiabloExample.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
require_once __DIR__.'/../vendor/autoload.php';
4+
5+
$client = new \BlizzardApi\BlizzardClient('apiKey', 'locale', 'region');
6+
7+
$diablo = new \BlizzardApi\Service\Diablo($client);
8+
9+
$response = $diablo->getItemDataById('Unique_Shoulder_103_x1');
10+
11+
// Show status code
12+
var_dump($response->getStatusCode());
13+
14+
// Show headers
15+
var_dump($response->getHeaders());
16+
17+
// Show response body
18+
echo $response->getBody();

examples/WorldOfWarcraftExample.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
require_once __DIR__.'/../vendor/autoload.php';
44

5-
$client = new \BlizzardApi\BlizzardClient('3hnw3qmca6bnc3x4japefbzhcd86smpr', 'en_US', 'US');
5+
$client = new \BlizzardApi\BlizzardClient('apiKey', 'locale', 'region');
66

77
$wow = new \BlizzardApi\Service\WorldOfWarcraft($client);
88

@@ -18,4 +18,3 @@
1818

1919
// Show response body
2020
echo $response->getBody();
21-

src/Service/Diablo.php

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
<?php
2+
3+
namespace BlizzardApi\Service;
4+
5+
use GuzzleHttp\Psr7\Response;
6+
7+
/**
8+
* Class Diablo
9+
*
10+
* @author Oleg Kachinsky <logansoleg@gmail.com>
11+
*/
12+
class Diablo extends Service
13+
{
14+
/**
15+
* {@inheritdoc}
16+
*/
17+
protected $serviceParam = '/d3';
18+
19+
// region Profile API
20+
21+
/**
22+
* Get career profile by battle tag
23+
*
24+
* Returns the career profile of a Battle Tag
25+
*
26+
* @param string $battleTag Battle Tag in name-#### format (ie. Noob-1234)
27+
* @param array $options Options
28+
*
29+
* @return Response
30+
*/
31+
public function getCareerProfile($battleTag, array $options = [])
32+
{
33+
return $this->request('/profile/'.(string) $battleTag.'/', $options);
34+
}
35+
36+
/**
37+
* Get hero profile by battle tag and hero id
38+
*
39+
* Returns the hero profile of a Battle Tag's hero
40+
*
41+
* @param string $battleTag Battle Tag in name-#### format (ie. Noob-1234)
42+
* @param string $heroId The hero id of the hero to look up
43+
* @param array $options Options
44+
*
45+
* @return Response
46+
*/
47+
public function getHeroProfile($battleTag, $heroId, array $options = [])
48+
{
49+
return $this->request('/profile/'.(string) $battleTag.'/hero/'.(int) $heroId, $options);
50+
}
51+
52+
// end region Profile API
53+
54+
// region Data resources API
55+
56+
/**
57+
* Get item data by item ID
58+
*
59+
* Returns data for a profile item
60+
*
61+
* @param string $itemId The item data string (from a profile) containing the item to lookup
62+
* @param array $options Options
63+
*
64+
* @return Response
65+
*/
66+
public function getItemDataById($itemId, array $options = [])
67+
{
68+
return $this->request('/data/item/'.(string) $itemId, $options);
69+
}
70+
71+
/**
72+
* Get follower data
73+
*
74+
* Returns data for a follower
75+
*
76+
* @param string $follower The data about a follower (enchantress, scoundrel, templar)
77+
* @param array $options Options
78+
*
79+
* @return Response
80+
*/
81+
public function getFollowerData($follower, array $options = [])
82+
{
83+
return $this->request('/data/follower/'.(string) $follower, $options);
84+
}
85+
86+
/**
87+
* Get artisan data
88+
*
89+
* Returns data for an artisan
90+
*
91+
* @param string $artisan The data about an artisan (blacksmith, jeweler, mystic)
92+
* @param array $options Options
93+
*
94+
* @return Response
95+
*/
96+
public function getArtisanData($artisan, array $options = [])
97+
{
98+
return $this->request('/data/artisan/'.(string) $artisan, $options);
99+
}
100+
101+
// end region Data resources API
102+
}

0 commit comments

Comments
 (0)