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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a9ebce85e9997c22f39aab934314d262fa95de225e2db78750e50e85ddcad1d6
4
- data.tar.gz: bdca1728c4c638fa426102981ccbf66c0d33665a23d79dc2893a9e1ad2e17fbd
3
+ metadata.gz: 7b186b91aa31a9888ae330a698bb6cd4b82ee584bc810586bfcabdc71cf07914
4
+ data.tar.gz: 2be4749b181b9a80f6961e440cc009b2f2959782d836c9df92b93e006815043f
5
5
  SHA512:
6
- metadata.gz: fb2470193915b595002c20bf2cdcbd38b16ea45448e00511d761b29c2c219c5d0acf1c36c539db1f7cf1e972bac2fde7635471a0f584bce0ef745840e5241dd6
7
- data.tar.gz: 512464cfed4cfb7fa7d331aa185a55d406f22d655b46245b3951e4bb0055a62cba6fd6648cbf36ccdf09bea4ef527229ab9c25453162028f516545faef1e936e
6
+ metadata.gz: '029f9e0695d934a2fa3d1c571ddb9331080711b8119c8534255f676f81cba0d274e7e679eb8bf7e82217128ff3d96432e5484ae7c61850db8145bd47ed1224b8'
7
+ data.tar.gz: 677c4b1f36bd14528554696b20a6ef3425abc7f4be572adf834b8596dbe70703b91f21fb1caa0c4caa2a037a21ad06f96736e69f32926684d63c26821a52fa64
data/.rubocop.yml CHANGED
@@ -3,6 +3,7 @@ AllCops:
3
3
  DisplayStyleGuide: true
4
4
  StyleGuideCopsOnly: true
5
5
  TargetRubyVersion: 3.2
6
+ SuggestExtensions: false
6
7
 
7
8
  Metrics/LineLength:
8
9
  Max: 140
data/Gemfile.lock CHANGED
@@ -1,17 +1,23 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- any_data_client (0.0.1)
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
- # AnyData
1
+ # AnyDataClient
2
2
 
3
- TODO: Delete this and the text below, and describe your gem
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
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
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
- $ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
9
+ gem 'any_data_client'
14
10
 
15
- If bundler is not being used to manage dependencies, install the gem by executing:
11
+ And then execute:
16
12
 
17
- $ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
13
+ ```sh
14
+ bundle install
15
+ ```
18
16
 
19
17
  ## Usage
20
18
 
21
- TODO: Write usage instructions here
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/[USERNAME]/any_data_client.
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
 
@@ -1,5 +1,31 @@
1
- require_relative 'any_data_client/version'
1
+ require 'net/http'
2
+ require 'uri'
2
3
 
3
- module AnyDataClient
4
- class Error < StandardError; end
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.1
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
@@ -1,3 +0,0 @@
1
- module AnyDataClient
2
- VERSION = '0.0.1'
3
- end