-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c533c00
commit 9954058
Showing
542 changed files
with
61,730 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Specify files that shouldn't be modified by Fern |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Publish | ||
|
||
on: [push] | ||
jobs: | ||
publish: | ||
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v3 | ||
|
||
- uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: 2.7 | ||
bundler-cache: true | ||
|
||
- name: Test gem | ||
run: bundle install && bundle exec rake test | ||
|
||
- name: Build and Push Gem | ||
env: | ||
GEM_HOST_API_KEY: ${{ secrets.RUBY_GEMS_API_KEY }} | ||
run: | | ||
gem build vapi.gemspec | ||
gem push vapi-*.gem --host https://rubygems.org/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/.bundle/ | ||
/.yardoc | ||
/_yardoc/ | ||
/coverage/ | ||
/doc/ | ||
/pkg/ | ||
/spec/reports/ | ||
/tmp/ | ||
*.gem | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
AllCops: | ||
TargetRubyVersion: 2.7 | ||
|
||
Style/StringLiterals: | ||
Enabled: true | ||
EnforcedStyle: double_quotes | ||
|
||
Style/StringLiteralsInInterpolation: | ||
Enabled: true | ||
EnforcedStyle: double_quotes | ||
|
||
Layout/FirstHashElementLineBreak: | ||
Enabled: true | ||
|
||
Layout/MultilineHashKeyLineBreaks: | ||
Enabled: true | ||
|
||
# Generated files may be more complex than standard, disable | ||
# these rules for now as a known limitation. | ||
Metrics/ParameterLists: | ||
Enabled: false | ||
|
||
Metrics/MethodLength: | ||
Enabled: false | ||
|
||
Metrics/AbcSize: | ||
Enabled: false | ||
|
||
Metrics/ClassLength: | ||
Enabled: false | ||
|
||
Metrics/CyclomaticComplexity: | ||
Enabled: false | ||
|
||
Metrics/PerceivedComplexity: | ||
Enabled: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# frozen_string_literal: true | ||
|
||
source "https://rubygems.org" | ||
|
||
gemspec | ||
|
||
gem "minitest", "~> 5.0" | ||
gem "rake", "~> 13.0" | ||
gem "rubocop", "~> 1.21" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +0,0 @@ | ||
# vapi-ruby-sdk | ||
The official Ruby SDK for accessing Vapi's API | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# frozen_string_literal: true | ||
|
||
require "rake/testtask" | ||
require "rubocop/rake_task" | ||
|
||
task default: %i[test rubocop] | ||
|
||
Rake::TestTask.new do |t| | ||
t.pattern = "./test/**/test_*.rb" | ||
end | ||
|
||
RuboCop::RakeTask.new |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# frozen_string_literal: true | ||
|
||
require "faraday/multipart" | ||
require "mini_mime" | ||
|
||
module Vapi | ||
# Utility class for managing files. | ||
class FileUtilities | ||
# @param file_like [String, IO] The file to be uploaded, or a string path to the file. | ||
# @return [Faraday::Multipart::FilePart] | ||
def self.as_faraday_multipart(file_like:) | ||
path = if file_like.is_a?(String) | ||
file_like | ||
else | ||
file_like.path | ||
end | ||
mime_type = MiniMime.lookup_by_filename(path) | ||
mime_type = if mime_type.nil? | ||
"application/octet-stream" | ||
else | ||
mime_type.content_type | ||
end | ||
Faraday::Multipart::FilePart.new(file_like, mime_type) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
module Vapi | ||
class Environment | ||
DEFAULT = "https://api.vapi.ai" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# frozen_string_literal: true | ||
|
||
module Vapi | ||
module Gemconfig | ||
VERSION = "" | ||
AUTHORS = [""].freeze | ||
EMAIL = "" | ||
SUMMARY = "" | ||
DESCRIPTION = "" | ||
HOMEPAGE = "https://github.com/fern-demo/vapi-ruby-sdk" | ||
SOURCE_CODE_URI = "https://github.com/fern-demo/vapi-ruby-sdk" | ||
CHANGELOG_URI = "https://github.com/fern-demo/vapi-ruby-sdk/blob/master/CHANGELOG.md" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "environment" | ||
require "faraday" | ||
require "faraday/multipart" | ||
require "faraday/retry" | ||
require "async/http/faraday" | ||
|
||
module Vapi | ||
class RequestClient | ||
# @return [Faraday] | ||
attr_reader :conn | ||
# @return [String] | ||
attr_reader :base_url | ||
# @return [String] | ||
attr_reader :token | ||
# @return [String] | ||
attr_reader :default_environment | ||
|
||
# @param base_url [String] | ||
# @param environment [Vapi::Environment] | ||
# @param max_retries [Long] The number of times to retry a failed request, defaults to 2. | ||
# @param timeout_in_seconds [Long] | ||
# @param token [String] | ||
# @return [Vapi::RequestClient] | ||
def initialize(token:, base_url: nil, environment: Vapi::Environment::DEFAULT, max_retries: nil, | ||
timeout_in_seconds: nil) | ||
@default_environment = environment | ||
@base_url = environment || base_url | ||
@token = "Bearer #{token}" | ||
@conn = Faraday.new do |faraday| | ||
faraday.request :multipart | ||
faraday.request :json | ||
faraday.response :raise_error, include_request: true | ||
faraday.request :retry, { max: max_retries } unless max_retries.nil? | ||
faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? | ||
end | ||
end | ||
|
||
# @param request_options [Vapi::RequestOptions] | ||
# @return [String] | ||
def get_url(request_options: nil) | ||
request_options&.base_url || @default_environment || @base_url | ||
end | ||
|
||
# @return [Hash{String => String}] | ||
def get_headers | ||
headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "vapi", "X-Fern-SDK-Version": "0.0.0" } | ||
headers["Authorization"] = ((@token.is_a? Method) ? @token.call : @token) unless @token.nil? | ||
headers | ||
end | ||
end | ||
|
||
class AsyncRequestClient | ||
# @return [Faraday] | ||
attr_reader :conn | ||
# @return [String] | ||
attr_reader :base_url | ||
# @return [String] | ||
attr_reader :token | ||
# @return [String] | ||
attr_reader :default_environment | ||
|
||
# @param base_url [String] | ||
# @param environment [Vapi::Environment] | ||
# @param max_retries [Long] The number of times to retry a failed request, defaults to 2. | ||
# @param timeout_in_seconds [Long] | ||
# @param token [String] | ||
# @return [Vapi::AsyncRequestClient] | ||
def initialize(token:, base_url: nil, environment: Vapi::Environment::DEFAULT, max_retries: nil, | ||
timeout_in_seconds: nil) | ||
@default_environment = environment | ||
@base_url = environment || base_url | ||
@token = "Bearer #{token}" | ||
@conn = Faraday.new do |faraday| | ||
faraday.request :multipart | ||
faraday.request :json | ||
faraday.response :raise_error, include_request: true | ||
faraday.adapter :async_http | ||
faraday.request :retry, { max: max_retries } unless max_retries.nil? | ||
faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? | ||
end | ||
end | ||
|
||
# @param request_options [Vapi::RequestOptions] | ||
# @return [String] | ||
def get_url(request_options: nil) | ||
request_options&.base_url || @default_environment || @base_url | ||
end | ||
|
||
# @return [Hash{String => String}] | ||
def get_headers | ||
headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "vapi", "X-Fern-SDK-Version": "0.0.0" } | ||
headers["Authorization"] = ((@token.is_a? Method) ? @token.call : @token) unless @token.nil? | ||
headers | ||
end | ||
end | ||
|
||
# Additional options for request-specific configuration when calling APIs via the | ||
# SDK. | ||
class RequestOptions | ||
# @return [String] | ||
attr_reader :base_url | ||
# @return [String] | ||
attr_reader :token | ||
# @return [Hash{String => Object}] | ||
attr_reader :additional_headers | ||
# @return [Hash{String => Object}] | ||
attr_reader :additional_query_parameters | ||
# @return [Hash{String => Object}] | ||
attr_reader :additional_body_parameters | ||
# @return [Long] | ||
attr_reader :timeout_in_seconds | ||
|
||
# @param base_url [String] | ||
# @param token [String] | ||
# @param additional_headers [Hash{String => Object}] | ||
# @param additional_query_parameters [Hash{String => Object}] | ||
# @param additional_body_parameters [Hash{String => Object}] | ||
# @param timeout_in_seconds [Long] | ||
# @return [Vapi::RequestOptions] | ||
def initialize(base_url: nil, token: nil, additional_headers: nil, additional_query_parameters: nil, | ||
additional_body_parameters: nil, timeout_in_seconds: nil) | ||
@base_url = base_url | ||
@token = token | ||
@additional_headers = additional_headers | ||
@additional_query_parameters = additional_query_parameters | ||
@additional_body_parameters = additional_body_parameters | ||
@timeout_in_seconds = timeout_in_seconds | ||
end | ||
end | ||
|
||
# Additional options for request-specific configuration when calling APIs via the | ||
# SDK. | ||
class IdempotencyRequestOptions | ||
# @return [String] | ||
attr_reader :base_url | ||
# @return [String] | ||
attr_reader :token | ||
# @return [Hash{String => Object}] | ||
attr_reader :additional_headers | ||
# @return [Hash{String => Object}] | ||
attr_reader :additional_query_parameters | ||
# @return [Hash{String => Object}] | ||
attr_reader :additional_body_parameters | ||
# @return [Long] | ||
attr_reader :timeout_in_seconds | ||
|
||
# @param base_url [String] | ||
# @param token [String] | ||
# @param additional_headers [Hash{String => Object}] | ||
# @param additional_query_parameters [Hash{String => Object}] | ||
# @param additional_body_parameters [Hash{String => Object}] | ||
# @param timeout_in_seconds [Long] | ||
# @return [Vapi::IdempotencyRequestOptions] | ||
def initialize(base_url: nil, token: nil, additional_headers: nil, additional_query_parameters: nil, | ||
additional_body_parameters: nil, timeout_in_seconds: nil) | ||
@base_url = base_url | ||
@token = token | ||
@additional_headers = additional_headers | ||
@additional_query_parameters = additional_query_parameters | ||
@additional_body_parameters = additional_body_parameters | ||
@timeout_in_seconds = timeout_in_seconds | ||
end | ||
end | ||
end |
Oops, something went wrong.