Repository: googlemaps/google-maps-services-js
Pull request #411 (2020-06-07 09:59:16)

fix(doc): typo

googlebot: 
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

:memo: **Please visit <https://cla.developers.google.com/> to sign.**

Once you've signed (or fixed any issues), please reply here with `@googlebot I signed it!` and we'll verify it.

----

#### What to do if you already signed the CLA

##### Individual signers

*   It's possible we don't have your GitHub username or you're using a different email address on your commit. Check [your existing CLA data](https://cla.developers.google.com/clas) and verify that your [email is set on your git commits](https://help.github.com/articles/setting-your-email-in-git/).

##### Corporate signers

*   Your company has a Point of Contact who decides which employees are authorized to participate. Ask your POC to be added to the group of authorized contributors. If you don't know who your Point of Contact is, direct the Google project maintainer to [go/cla#troubleshoot](http://go/cla#troubleshoot) ([Public version](https://opensource.google/docs/cla/#troubleshoot)).
*   The email used to register you as an authorized contributor must be the email used for the Git commit. Check [your existing CLA data](https://cla.developers.google.com/clas) and verify that your [email is set on your git commits](https://help.github.com/articles/setting-your-email-in-git/).
*   The email used to register you as an authorized contributor must also be [attached to your GitHub account](https://github.com/settings/emails).
		

ℹ️ **Googlers: [Go here](https://goto.google.com/prinfo/https%3A%2F%2Fgithub.com%2Fgooglemaps%2Fgoogle-maps-services-js%2Fpull%2F411) for more info**.

<!-- need_sender_cla -->
codecov[bot]: # [Codecov](https://codecov.io/gh/googlemaps/google-maps-services-js/pull/411?src=pr&el=h1) Report
> Merging [#411](https://codecov.io/gh/googlemaps/google-maps-services-js/pull/411?src=pr&el=desc) into [master](https://codecov.io/gh/googlemaps/google-maps-services-js/commit/090141db1f8874814fef6f584eacd2567192868d&el=desc) will **decrease** coverage by `1.05%`.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/googlemaps/google-maps-services-js/pull/411/graphs/tree.svg?width=650&height=150&src=pr&token=wXidzRKqFM)](https://codecov.io/gh/googlemaps/google-maps-services-js/pull/411?src=pr&el=tree)

```diff
@@             Coverage Diff             @@
##            master     #411      +/-   ##
===========================================
- Coverage   100.00%   98.94%   -1.06%     
===========================================
  Files           22       22              
  Lines          760      760              
  Branches       124      124              
===========================================
- Hits           760      752       -8     
- Misses           0        8       +8     
```


| [Impacted Files](https://codecov.io/gh/googlemaps/google-maps-services-js/pull/411?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [src/distance.ts](https://codecov.io/gh/googlemaps/google-maps-services-js/pull/411/diff?src=pr&el=tree#diff-c3JjL2Rpc3RhbmNlLnRz) | `84.61% <0.00%> (-15.39%)` | :arrow_down: |
| [src/elevation.ts](https://codecov.io/gh/googlemaps/google-maps-services-js/pull/411/diff?src=pr&el=tree#diff-c3JjL2VsZXZhdGlvbi50cw==) | `84.61% <0.00%> (-15.39%)` | :arrow_down: |
| [src/directions.ts](https://codecov.io/gh/googlemaps/google-maps-services-js/pull/411/diff?src=pr&el=tree#diff-c3JjL2RpcmVjdGlvbnMudHM=) | `87.50% <0.00%> (-12.50%)` | :arrow_down: |
| [src/roads/snaptoroads.ts](https://codecov.io/gh/googlemaps/google-maps-services-js/pull/411/diff?src=pr&el=tree#diff-c3JjL3JvYWRzL3NuYXB0b3JvYWRzLnRz) | `91.66% <0.00%> (-8.34%)` | :arrow_down: |
| [src/roads/nearestroads.ts](https://codecov.io/gh/googlemaps/google-maps-services-js/pull/411/diff?src=pr&el=tree#diff-c3JjL3JvYWRzL25lYXJlc3Ryb2Fkcy50cw==) | `91.66% <0.00%> (-8.34%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/googlemaps/google-maps-services-js/pull/411?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/googlemaps/google-maps-services-js/pull/411?src=pr&el=footer). Last update [090141d...5fed9ea](https://codecov.io/gh/googlemaps/google-maps-services-js/pull/411?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/src/geocode/geocode.ts b/src/geocode/geocode.ts
index 23b9b1e59..55464bf41 100644
--- a/src/geocode/geocode.ts
+++ b/src/geocode/geocode.ts
@@ -40,6 +40,10 @@ export interface GeocodeComponents {
 
 export interface GeocodeRequest extends Partial<AxiosRequestConfig> {
   params: {
+    /**
+     * The place_id that you want to geocode. You can retrieve this information from Places API for example.
+     */
+    place_id?: string;
     /**
      * The street address that you want to geocode, in the format used by the national postal service of the country concerned.
      * Additional address elements such as business names and unit, suite or floor numbers should be avoided.
diff --git a/src/places/photo.ts b/src/places/photo.ts
index 09d5cbd3b..70474cd1e 100644
--- a/src/places/photo.ts
+++ b/src/places/photo.ts
@@ -40,6 +40,7 @@ export interface PlacePhotoRequest extends Partial<AxiosRequestConfig> {
      */
     maxheight?: number;
     } & RequestParams;
+  responseType: 'arraybuffer' | 'blob' | 'stream';
 }
 
 /**
@@ -59,13 +60,18 @@ export interface PlacePhotoResponse extends AxiosResponse {}
 export const defaultUrl = "https://maps.googleapis.com/maps/api/place/photo";
 
 export function placePhoto(
-  { params, method = "get", url = defaultUrl, ...config }: PlacePhotoRequest,
+  { params, method = "get", url = defaultUrl, responseType, ...config }: PlacePhotoRequest,
   axiosInstance: AxiosInstance = defaultAxiosInstance
 ): Promise<PlacePhotoResponse> {
+  if (!responseType) {
+    responseType = 'arraybuffer'
+  }
+
   return axiosInstance({
     params,
     method,
     url,
+    responseType,
     ...config
   }) as Promise<PlacePhotoResponse>;
 }


Test patch:
diff --git a/e2e/places/details.test.ts b/e2e/places/details.test.ts
index 7548ba9c0..861c329f8 100644
--- a/e2e/places/details.test.ts
+++ b/e2e/places/details.test.ts
@@ -16,7 +16,7 @@
 
 import { placeDetails } from "../../src/places/details";
 
-test("autocomplete should return correct result", async () => {
+test("details should return correct result", async () => {
   const params = {
     place_id: "ChIJKxDbe_lYwokRVf__s8CPn-o",
     key: process.env.GOOGLE_MAPS_API_KEY,
diff --git a/e2e/places/photo.test.ts b/e2e/places/photo.test.ts
index 56ec4ed62..1fddd2c45 100644
--- a/e2e/places/photo.test.ts
+++ b/e2e/places/photo.test.ts
@@ -15,7 +15,6 @@
  */
 
 import { placePhoto } from "../../src/places/photo";
-import { PlaceInputType } from "../../src/common";
 
 test("photo should return correct result", async () => {
   const params = {
@@ -23,9 +22,9 @@ test("photo should return correct result", async () => {
       "CnRtAAAATLZNl354RwP_9UKbQ_5Psy40texXePv4oAlgP4qNEkdIrkyse7rPXYGd9D_Uj1rVsQdWT4oRz4QrYAJNpFX7rzqqMlZw2h2E2y5IKMUZ7ouD_SlcHxYq1yL4KbKUv3qtWgTK0A6QbGh87GB3sscrHRIQiG2RrmU_jF4tENr9wGS_YxoUSSDrYjWmrNfeEHSGSc3FyhNLlBU",
     maxwidth: 100,
     maxheight: 100,
-    key: process.env.GOOGLE_MAPS_API_KEY
+    key: process.env.GOOGLE_MAPS_API_KEY,
   };
-  const r = await placePhoto({ params: params });
+  const r = await placePhoto({ params: params, responseType: "arraybuffer" });
 
   expect(r.status).toEqual(200);
   expect(r.headers["content-type"]).toEqual("image/jpeg");
diff --git a/src/places/photo.test.ts b/src/places/photo.test.ts
index 682318529..a79a535b2 100644
--- a/src/places/photo.test.ts
+++ b/src/places/photo.test.ts
@@ -15,7 +15,7 @@
  */
 
 import axios from "axios";
-import { placePhoto, defaultUrl } from "./photo";
+import { placePhoto, defaultUrl, PlacePhotoRequest } from "./photo";
 
 jest.mock("axios");
 
@@ -27,13 +27,27 @@ afterEach(() => {
 
 test("photo should call axios correctly", () => {
   const params = { photoreference: "notaphotoreference", key: "foo" };
+  const responseType = 'arraybuffer';
+  placePhoto({ params, responseType }, mockedAxios);
 
-  placePhoto({ params: params }, mockedAxios);
+  expect(mockedAxios).toHaveBeenCalledTimes(1);
+  expect(mockedAxios).toHaveBeenCalledWith({
+    method: "get",
+    params,
+    responseType,
+    url: defaultUrl,
+  });
+});
+
+test("photo should set default responseType", () => {
+  const params = { photoreference: "notaphotoreference", key: "foo" };
+  placePhoto({ params } as PlacePhotoRequest, mockedAxios);
 
   expect(mockedAxios).toHaveBeenCalledTimes(1);
   expect(mockedAxios).toHaveBeenCalledWith({
     method: "get",
-    params: params,
-    url: defaultUrl
+    params,
+    responseType: "arraybuffer",
+    url: defaultUrl,
   });
 });