Skip to content

Commit ac347a2

Browse files
committed
・Add Example
- Update Readme
1 parent be51900 commit ac347a2

File tree

6 files changed

+184
-27
lines changed

6 files changed

+184
-27
lines changed

README.md

+61-16
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,61 @@
1-
# theta-client-js
2-
Theta client for javascript.
3-
4-
## Installing
5-
6-
## Example
7-
8-
### HTTP Example
9-
10-
## Theta Client API
11-
12-
### HTTP API
13-
14-
### API Reference(TypeDoc)
15-
16-
https://goroya.github.io/theta-api-client.js/
1+
# theta-api-client.js
2+
Theta client for javascript.
3+
4+
# Supported Platforms
5+
6+
- Node.js
7+
- React Native
8+
9+
## Installing
10+
11+
```bash
12+
$ npm install @goroya.io/theta-api-client --save
13+
```
14+
15+
## Example
16+
17+
### HTTP Example
18+
19+
### Node.js Example
20+
```javascript
21+
const {ThetaHttpClient} = require('@goroya.io/theta-api-client');
22+
23+
(async () => {
24+
this.thetaClient = new ThetaHttpClient({
25+
hostname: '192.168.1.1',
26+
axiosConfig: {},
27+
auth: { user: 'THETAYLxxxxxxxx', pass: 'xxxxxxxx' }
28+
});
29+
await this.thetaClient
30+
.cameraTakePicture({
31+
timeout: 3000
32+
})
33+
.catch(e => {
34+
console.error('error:', e);
35+
});
36+
})();
37+
```
38+
39+
### ES Modules & TypeScript & React Native
40+
41+
```javascript
42+
import { ThetaHttpClient } from '@goroya.io/theta-api-client';
43+
44+
this.thetaClient = new ThetaHttpClient({
45+
hostname: '192.168.1.1',
46+
axiosConfig: {},
47+
auth: { user: 'THETAYLxxxxxxxx', pass: 'xxxxxxxx' }
48+
});
49+
(async () => {
50+
const ret = await thetaClient.cameraTakePicture();
51+
})();
52+
```
53+
54+
## Theta Client API
55+
56+
### HTTP API
57+
58+
### TypeDoc Document
59+
https://goroya.github.io/theta-api-client.js/classes/thetahttpclient.html
60+
61+
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const {ThetaHttpClient} = require('@goroya.io/theta-api-client');
2+
3+
(async () => {
4+
this.thetaClient = new ThetaHttpClient({
5+
hostname: '192.168.1.1',
6+
axiosConfig: {},
7+
auth: { user: 'THETAYLxxxxxxxx', pass: 'xxxxxxxx' }
8+
});
9+
await this.thetaClient
10+
.cameraTakePicture({
11+
timeout: 3000
12+
})
13+
.catch(e => {
14+
console.error('error:', e);
15+
});
16+
})();

example/node/take-picture-example/package-lock.json

+63
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "@goroya.io/take-picture-example",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "main.js",
6+
"scripts": {
7+
"start": "node main.js"
8+
},
9+
"dependencies": {
10+
"@goroya.io/theta-api-client": "*"
11+
},
12+
"author": "",
13+
"license": "ISC"
14+
}

example/react-native/theta-example/App.tsx

+29-10
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,48 @@
11
import { ThetaHttpClient } from '@goroya.io/theta-api-client';
22
import React from 'react';
3-
import { Button, StyleSheet, Text, View } from 'react-native';
3+
import { Button, StyleSheet, Text, TextInput, View } from 'react-native';
44

5-
export default class App extends React.Component {
5+
export default class App extends React.Component<any, any> {
66
private thetaClient: ThetaHttpClient;
77
constructor(props: Readonly<{}>) {
88
super(props);
9+
this.state = { thetaIP: '192.168.1.1' };
910
this.thetaClient = new ThetaHttpClient({
10-
hostname: '192.168.100.18',
11+
hostname: '192.168.1.1',
1112
axiosConfig: {},
12-
auth: { user: 'THETAYL00106013', pass: '00106013' }
13+
auth: { user: 'THETAYLxxxxxxxx', pass: 'xxxxxxxx' }
1314
});
14-
this.onPressLearnMore.bind(this);
15+
this.onPressTakePicture = this.onPressTakePicture.bind(this);
1516
}
16-
public async onPressLearnMore() {
17-
console.log('Push');
18-
console.log();
19-
await this.thetaClient.cameraTakePicture();
17+
public async onPressTakePicture() {
18+
console.log("take start");
19+
await this.thetaClient
20+
.cameraTakePicture({
21+
baseURL: `http://${this.state.thetaIP}`,
22+
timeout: 3000
23+
})
24+
.catch(e => {
25+
console.error('error:', e);
26+
});
27+
console.log("take stop");
2028
}
2129
public render() {
2230
return (
2331
<View style={styles.container}>
2432
<Text>Theta Example</Text>
33+
<TextInput
34+
style={{
35+
height: 40,
36+
width: 150,
37+
borderColor: 'gray',
38+
borderWidth: 1,
39+
textAlign: 'center'
40+
}}
41+
onChangeText={thetaIP => this.setState({ thetaIP })}
42+
value={this.state.thetaIP}
43+
/>
2544
<Button
26-
onPress={this.onPressLearnMore}
45+
onPress={this.onPressTakePicture}
2746
title="Take a Picture"
2847
color="#841584"
2948
/>

example/react-native/theta-example/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"eject": "expo eject"
88
},
99
"dependencies": {
10-
"@goroya.io/theta-api-client": "0.0.1",
10+
"@goroya.io/theta-api-client": "*",
1111
"expo": "^32.0.0",
1212
"react": "16.5.0",
1313
"react-native": "https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz"

0 commit comments

Comments
 (0)