Skip to content

Commit 9954058

Browse files
committed
Release 0.0.0
1 parent c533c00 commit 9954058

File tree

542 files changed

+61730
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

542 files changed

+61730
-2
lines changed

.fernignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Specify files that shouldn't be modified by Fern

.github/workflows/publish.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Publish
2+
3+
on: [push]
4+
jobs:
5+
publish:
6+
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Checkout repo
10+
uses: actions/checkout@v3
11+
12+
- uses: ruby/setup-ruby@v1
13+
with:
14+
ruby-version: 2.7
15+
bundler-cache: true
16+
17+
- name: Test gem
18+
run: bundle install && bundle exec rake test
19+
20+
- name: Build and Push Gem
21+
env:
22+
GEM_HOST_API_KEY: ${{ secrets.RUBY_GEMS_API_KEY }}
23+
run: |
24+
gem build vapi.gemspec
25+
26+
gem push vapi-*.gem --host https://rubygems.org/

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/.bundle/
2+
/.yardoc
3+
/_yardoc/
4+
/coverage/
5+
/doc/
6+
/pkg/
7+
/spec/reports/
8+
/tmp/
9+
*.gem
10+
.env

.rubocop.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
AllCops:
2+
TargetRubyVersion: 2.7
3+
4+
Style/StringLiterals:
5+
Enabled: true
6+
EnforcedStyle: double_quotes
7+
8+
Style/StringLiteralsInInterpolation:
9+
Enabled: true
10+
EnforcedStyle: double_quotes
11+
12+
Layout/FirstHashElementLineBreak:
13+
Enabled: true
14+
15+
Layout/MultilineHashKeyLineBreaks:
16+
Enabled: true
17+
18+
# Generated files may be more complex than standard, disable
19+
# these rules for now as a known limitation.
20+
Metrics/ParameterLists:
21+
Enabled: false
22+
23+
Metrics/MethodLength:
24+
Enabled: false
25+
26+
Metrics/AbcSize:
27+
Enabled: false
28+
29+
Metrics/ClassLength:
30+
Enabled: false
31+
32+
Metrics/CyclomaticComplexity:
33+
Enabled: false
34+
35+
Metrics/PerceivedComplexity:
36+
Enabled: false

Gemfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# frozen_string_literal: true
2+
3+
source "https://rubygems.org"
4+
5+
gemspec
6+
7+
gem "minitest", "~> 5.0"
8+
gem "rake", "~> 13.0"
9+
gem "rubocop", "~> 1.21"

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +0,0 @@
1-
# vapi-ruby-sdk
2-
The official Ruby SDK for accessing Vapi's API

Rakefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# frozen_string_literal: true
2+
3+
require "rake/testtask"
4+
require "rubocop/rake_task"
5+
6+
task default: %i[test rubocop]
7+
8+
Rake::TestTask.new do |t|
9+
t.pattern = "./test/**/test_*.rb"
10+
end
11+
12+
RuboCop::RakeTask.new

lib/core/file_utilities.rb

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# frozen_string_literal: true
2+
3+
require "faraday/multipart"
4+
require "mini_mime"
5+
6+
module Vapi
7+
# Utility class for managing files.
8+
class FileUtilities
9+
# @param file_like [String, IO] The file to be uploaded, or a string path to the file.
10+
# @return [Faraday::Multipart::FilePart]
11+
def self.as_faraday_multipart(file_like:)
12+
path = if file_like.is_a?(String)
13+
file_like
14+
else
15+
file_like.path
16+
end
17+
mime_type = MiniMime.lookup_by_filename(path)
18+
mime_type = if mime_type.nil?
19+
"application/octet-stream"
20+
else
21+
mime_type.content_type
22+
end
23+
Faraday::Multipart::FilePart.new(file_like, mime_type)
24+
end
25+
end
26+
end

lib/environment.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# frozen_string_literal: true
2+
3+
module Vapi
4+
class Environment
5+
DEFAULT = "https://api.vapi.ai"
6+
end
7+
end

lib/gemconfig.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# frozen_string_literal: true
2+
3+
module Vapi
4+
module Gemconfig
5+
VERSION = ""
6+
AUTHORS = [""].freeze
7+
EMAIL = ""
8+
SUMMARY = ""
9+
DESCRIPTION = ""
10+
HOMEPAGE = "https://github.com/fern-demo/vapi-ruby-sdk"
11+
SOURCE_CODE_URI = "https://github.com/fern-demo/vapi-ruby-sdk"
12+
CHANGELOG_URI = "https://github.com/fern-demo/vapi-ruby-sdk/blob/master/CHANGELOG.md"
13+
end
14+
end

lib/requests.rb

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
# frozen_string_literal: true
2+
3+
require_relative "environment"
4+
require "faraday"
5+
require "faraday/multipart"
6+
require "faraday/retry"
7+
require "async/http/faraday"
8+
9+
module Vapi
10+
class RequestClient
11+
# @return [Faraday]
12+
attr_reader :conn
13+
# @return [String]
14+
attr_reader :base_url
15+
# @return [String]
16+
attr_reader :token
17+
# @return [String]
18+
attr_reader :default_environment
19+
20+
# @param base_url [String]
21+
# @param environment [Vapi::Environment]
22+
# @param max_retries [Long] The number of times to retry a failed request, defaults to 2.
23+
# @param timeout_in_seconds [Long]
24+
# @param token [String]
25+
# @return [Vapi::RequestClient]
26+
def initialize(token:, base_url: nil, environment: Vapi::Environment::DEFAULT, max_retries: nil,
27+
timeout_in_seconds: nil)
28+
@default_environment = environment
29+
@base_url = environment || base_url
30+
@token = "Bearer #{token}"
31+
@conn = Faraday.new do |faraday|
32+
faraday.request :multipart
33+
faraday.request :json
34+
faraday.response :raise_error, include_request: true
35+
faraday.request :retry, { max: max_retries } unless max_retries.nil?
36+
faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil?
37+
end
38+
end
39+
40+
# @param request_options [Vapi::RequestOptions]
41+
# @return [String]
42+
def get_url(request_options: nil)
43+
request_options&.base_url || @default_environment || @base_url
44+
end
45+
46+
# @return [Hash{String => String}]
47+
def get_headers
48+
headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "vapi", "X-Fern-SDK-Version": "0.0.0" }
49+
headers["Authorization"] = ((@token.is_a? Method) ? @token.call : @token) unless @token.nil?
50+
headers
51+
end
52+
end
53+
54+
class AsyncRequestClient
55+
# @return [Faraday]
56+
attr_reader :conn
57+
# @return [String]
58+
attr_reader :base_url
59+
# @return [String]
60+
attr_reader :token
61+
# @return [String]
62+
attr_reader :default_environment
63+
64+
# @param base_url [String]
65+
# @param environment [Vapi::Environment]
66+
# @param max_retries [Long] The number of times to retry a failed request, defaults to 2.
67+
# @param timeout_in_seconds [Long]
68+
# @param token [String]
69+
# @return [Vapi::AsyncRequestClient]
70+
def initialize(token:, base_url: nil, environment: Vapi::Environment::DEFAULT, max_retries: nil,
71+
timeout_in_seconds: nil)
72+
@default_environment = environment
73+
@base_url = environment || base_url
74+
@token = "Bearer #{token}"
75+
@conn = Faraday.new do |faraday|
76+
faraday.request :multipart
77+
faraday.request :json
78+
faraday.response :raise_error, include_request: true
79+
faraday.adapter :async_http
80+
faraday.request :retry, { max: max_retries } unless max_retries.nil?
81+
faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil?
82+
end
83+
end
84+
85+
# @param request_options [Vapi::RequestOptions]
86+
# @return [String]
87+
def get_url(request_options: nil)
88+
request_options&.base_url || @default_environment || @base_url
89+
end
90+
91+
# @return [Hash{String => String}]
92+
def get_headers
93+
headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "vapi", "X-Fern-SDK-Version": "0.0.0" }
94+
headers["Authorization"] = ((@token.is_a? Method) ? @token.call : @token) unless @token.nil?
95+
headers
96+
end
97+
end
98+
99+
# Additional options for request-specific configuration when calling APIs via the
100+
# SDK.
101+
class RequestOptions
102+
# @return [String]
103+
attr_reader :base_url
104+
# @return [String]
105+
attr_reader :token
106+
# @return [Hash{String => Object}]
107+
attr_reader :additional_headers
108+
# @return [Hash{String => Object}]
109+
attr_reader :additional_query_parameters
110+
# @return [Hash{String => Object}]
111+
attr_reader :additional_body_parameters
112+
# @return [Long]
113+
attr_reader :timeout_in_seconds
114+
115+
# @param base_url [String]
116+
# @param token [String]
117+
# @param additional_headers [Hash{String => Object}]
118+
# @param additional_query_parameters [Hash{String => Object}]
119+
# @param additional_body_parameters [Hash{String => Object}]
120+
# @param timeout_in_seconds [Long]
121+
# @return [Vapi::RequestOptions]
122+
def initialize(base_url: nil, token: nil, additional_headers: nil, additional_query_parameters: nil,
123+
additional_body_parameters: nil, timeout_in_seconds: nil)
124+
@base_url = base_url
125+
@token = token
126+
@additional_headers = additional_headers
127+
@additional_query_parameters = additional_query_parameters
128+
@additional_body_parameters = additional_body_parameters
129+
@timeout_in_seconds = timeout_in_seconds
130+
end
131+
end
132+
133+
# Additional options for request-specific configuration when calling APIs via the
134+
# SDK.
135+
class IdempotencyRequestOptions
136+
# @return [String]
137+
attr_reader :base_url
138+
# @return [String]
139+
attr_reader :token
140+
# @return [Hash{String => Object}]
141+
attr_reader :additional_headers
142+
# @return [Hash{String => Object}]
143+
attr_reader :additional_query_parameters
144+
# @return [Hash{String => Object}]
145+
attr_reader :additional_body_parameters
146+
# @return [Long]
147+
attr_reader :timeout_in_seconds
148+
149+
# @param base_url [String]
150+
# @param token [String]
151+
# @param additional_headers [Hash{String => Object}]
152+
# @param additional_query_parameters [Hash{String => Object}]
153+
# @param additional_body_parameters [Hash{String => Object}]
154+
# @param timeout_in_seconds [Long]
155+
# @return [Vapi::IdempotencyRequestOptions]
156+
def initialize(base_url: nil, token: nil, additional_headers: nil, additional_query_parameters: nil,
157+
additional_body_parameters: nil, timeout_in_seconds: nil)
158+
@base_url = base_url
159+
@token = token
160+
@additional_headers = additional_headers
161+
@additional_query_parameters = additional_query_parameters
162+
@additional_body_parameters = additional_body_parameters
163+
@timeout_in_seconds = timeout_in_seconds
164+
end
165+
end
166+
end

0 commit comments

Comments
 (0)