Skip to content

Commit

Permalink
Release 0.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-api[bot] committed Sep 16, 2024
1 parent c533c00 commit 9954058
Show file tree
Hide file tree
Showing 542 changed files with 61,730 additions and 2 deletions.
1 change: 1 addition & 0 deletions .fernignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Specify files that shouldn't be modified by Fern
26 changes: 26 additions & 0 deletions .github/workflows/publish.yml
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/
10 changes: 10 additions & 0 deletions .gitignore
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
36 changes: 36 additions & 0 deletions .rubocop.yml
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
9 changes: 9 additions & 0 deletions Gemfile
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"
2 changes: 0 additions & 2 deletions README.md
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
12 changes: 12 additions & 0 deletions Rakefile
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
26 changes: 26 additions & 0 deletions lib/core/file_utilities.rb
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
7 changes: 7 additions & 0 deletions lib/environment.rb
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
14 changes: 14 additions & 0 deletions lib/gemconfig.rb
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
166 changes: 166 additions & 0 deletions lib/requests.rb
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
Loading

0 comments on commit 9954058

Please sign in to comment.