any_data_client 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -0
- data/Gemfile.lock +12 -1
- data/README.md +40 -12
- data/lib/any_data_client.rb +29 -3
- metadata +30 -3
- data/lib/any_data_client/version.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b186b91aa31a9888ae330a698bb6cd4b82ee584bc810586bfcabdc71cf07914
|
4
|
+
data.tar.gz: 2be4749b181b9a80f6961e440cc009b2f2959782d836c9df92b93e006815043f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '029f9e0695d934a2fa3d1c571ddb9331080711b8119c8534255f676f81cba0d274e7e679eb8bf7e82217128ff3d96432e5484ae7c61850db8145bd47ed1224b8'
|
7
|
+
data.tar.gz: 677c4b1f36bd14528554696b20a6ef3425abc7f4be572adf834b8596dbe70703b91f21fb1caa0c4caa2a037a21ad06f96736e69f32926684d63c26821a52fa64
|
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,17 +1,23 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
any_data_client (0.0
|
4
|
+
any_data_client (0.1.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
+
addressable (2.8.4)
|
10
|
+
public_suffix (>= 2.0.2, < 6.0)
|
9
11
|
ast (2.4.2)
|
12
|
+
crack (0.4.5)
|
13
|
+
rexml
|
10
14
|
diff-lcs (1.5.0)
|
15
|
+
hashdiff (1.0.1)
|
11
16
|
json (2.6.3)
|
12
17
|
parallel (1.23.0)
|
13
18
|
parser (3.2.2.1)
|
14
19
|
ast (~> 2.4.1)
|
20
|
+
public_suffix (5.0.1)
|
15
21
|
rainbow (3.1.1)
|
16
22
|
rake (13.0.6)
|
17
23
|
regexp_parser (2.8.0)
|
@@ -43,6 +49,10 @@ GEM
|
|
43
49
|
parser (>= 3.2.1.0)
|
44
50
|
ruby-progressbar (1.13.0)
|
45
51
|
unicode-display_width (2.4.2)
|
52
|
+
webmock (3.18.1)
|
53
|
+
addressable (>= 2.8.0)
|
54
|
+
crack (>= 0.3.2)
|
55
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
46
56
|
|
47
57
|
PLATFORMS
|
48
58
|
arm64-darwin-22
|
@@ -53,6 +63,7 @@ DEPENDENCIES
|
|
53
63
|
rake (~> 13.0)
|
54
64
|
rspec (~> 3.0)
|
55
65
|
rubocop (~> 1.21)
|
66
|
+
webmock
|
56
67
|
|
57
68
|
BUNDLED WITH
|
58
69
|
2.4.6
|
data/README.md
CHANGED
@@ -1,24 +1,52 @@
|
|
1
|
-
#
|
1
|
+
# AnyDataClient
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/any_data_client`. To experiment with that code, run `bin/console` for an interactive prompt.
|
3
|
+
Ruby gem that provides a simple API client for the AnyData.
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
9
|
-
|
10
|
-
|
11
|
-
Install the gem and add to the application's Gemfile by executing:
|
7
|
+
Add the `any_data_client` gem to your application's Gemfile:
|
12
8
|
|
13
|
-
|
9
|
+
gem 'any_data_client'
|
14
10
|
|
15
|
-
|
11
|
+
And then execute:
|
16
12
|
|
17
|
-
|
13
|
+
```sh
|
14
|
+
bundle install
|
15
|
+
```
|
18
16
|
|
19
17
|
## Usage
|
20
18
|
|
21
|
-
|
19
|
+
To use the `any_data_client` gem, first require it in your code:
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
require 'any_data_client'
|
23
|
+
```
|
24
|
+
|
25
|
+
Then, create an instance of the `AnyDataClient` class and provide the API endpoint:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
client = AnyDataClient.new(api_endpoint: 'https://anydata.fly.dev/api/v1/events')
|
29
|
+
```
|
30
|
+
|
31
|
+
Now you can use the client to interact with the AnyData Events API. For example, to create new event:
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
event = { name: 'API call' }
|
35
|
+
response = client.create_event(event)
|
36
|
+
```
|
37
|
+
|
38
|
+
Also, you can add properties which are optional:
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
event = {
|
42
|
+
name: 'API call',
|
43
|
+
properties: {
|
44
|
+
action: 'create',
|
45
|
+
endpoint: 'users'
|
46
|
+
}
|
47
|
+
}
|
48
|
+
response = client.create_event(event)
|
49
|
+
```
|
22
50
|
|
23
51
|
## Development
|
24
52
|
|
@@ -28,7 +56,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
28
56
|
|
29
57
|
## Contributing
|
30
58
|
|
31
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
59
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/kirillshevch/any_data_client.
|
32
60
|
|
33
61
|
## License
|
34
62
|
|
data/lib/any_data_client.rb
CHANGED
@@ -1,5 +1,31 @@
|
|
1
|
-
|
1
|
+
require 'net/http'
|
2
|
+
require 'uri'
|
2
3
|
|
3
|
-
|
4
|
-
|
4
|
+
class AnyDataClient
|
5
|
+
def initialize(base_url, api_key)
|
6
|
+
@base_url = base_url
|
7
|
+
@api_key = api_key
|
8
|
+
end
|
9
|
+
|
10
|
+
def create_event(params)
|
11
|
+
request('/api/v1/events', params)
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def request(path, params = nil)
|
17
|
+
uri = URI.join(@base_url, path)
|
18
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
19
|
+
http.use_ssl = true
|
20
|
+
|
21
|
+
headers = {
|
22
|
+
'Content-Type' => 'application/json',
|
23
|
+
'Authorization' => "Bearer #{@api_key}"
|
24
|
+
}
|
25
|
+
|
26
|
+
req = Net::HTTP::Post.new(uri, headers)
|
27
|
+
req.body = params.to_json if params
|
28
|
+
|
29
|
+
http.request(req)
|
30
|
+
end
|
5
31
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: any_data_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kirill Shevchenko
|
@@ -9,7 +9,35 @@ autorequire:
|
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
11
|
date: 2023-05-08 00:00:00.000000000 Z
|
12
|
-
dependencies:
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: webmock
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
13
41
|
description: Official Ruby client for AnyData API
|
14
42
|
email:
|
15
43
|
- kirills167@gmail.com
|
@@ -25,7 +53,6 @@ files:
|
|
25
53
|
- README.md
|
26
54
|
- Rakefile
|
27
55
|
- lib/any_data_client.rb
|
28
|
-
- lib/any_data_client/version.rb
|
29
56
|
homepage: https://github.com/kirillshevch/any_data_client
|
30
57
|
licenses:
|
31
58
|
- MIT
|