repo stringlengths 5 92 | file_url stringlengths 80 287 | file_path stringlengths 5 197 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:37:27 2026-01-04 17:58:21 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/discovery/marketing/events/api/add_event_attendees_api.rb | lib/hubspot/discovery/marketing/events/api/add_event_attendees_api.rb | require_relative '../../../base_api_client'
module Hubspot
module Discovery
module Marketing
module Events
class AddEventAttendeesApi
include Hubspot::Discovery::BaseApiClient
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/discovery/marketing/events/api/identifiers_api.rb | lib/hubspot/discovery/marketing/events/api/identifiers_api.rb | require_relative '../../../base_api_client'
module Hubspot
module Discovery
module Marketing
module Events
class IdentifiersApi
include Hubspot::Discovery::BaseApiClient
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/discovery/marketing/events/api/settings_api.rb | lib/hubspot/discovery/marketing/events/api/settings_api.rb | require_relative '../../../base_api_client'
module Hubspot
module Discovery
module Marketing
module Events
class SettingsApi
include Hubspot::Discovery::BaseApiClient
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/discovery/marketing/events/api/list_associations_api.rb | lib/hubspot/discovery/marketing/events/api/list_associations_api.rb | require_relative '../../../base_api_client'
module Hubspot
module Discovery
module Marketing
module Events
class ListAssociationsApi
include Hubspot::Discovery::BaseApiClient
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/discovery/marketing/transactional/client.rb | lib/hubspot/discovery/marketing/transactional/client.rb | require_relative '../../base_module_client'
module Hubspot
module Discovery
module Marketing
module Transactional
class Client
include Hubspot::Discovery::BaseModuleClient
def api_classes
%i[
public_smtp_tokens
single_send
].freeze
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/discovery/marketing/transactional/api/public_smtp_tokens_api.rb | lib/hubspot/discovery/marketing/transactional/api/public_smtp_tokens_api.rb | require_relative '../../../base_api_client'
module Hubspot
module Discovery
module Marketing
module Transactional
class PublicSMTPTokensApi
include Hubspot::Discovery::BaseApiClient
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/discovery/marketing/transactional/api/single_send_api.rb | lib/hubspot/discovery/marketing/transactional/api/single_send_api.rb | require_relative '../../../base_api_client'
module Hubspot
module Discovery
module Marketing
module Transactional
class SingleSendApi
include Hubspot::Discovery::BaseApiClient
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/discovery/cms/client.rb | lib/hubspot/discovery/cms/client.rb | require_relative '../base_module_client'
module Hubspot
module Discovery
module Cms
class Client
include Hubspot::Discovery::BaseModuleClient
def api_modules
%i[
audit_logs
blogs
domains
hubdb
pages
site_search
source_code
url_redirects
].freeze
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/discovery/cms/audit_logs/client.rb | lib/hubspot/discovery/cms/audit_logs/client.rb | require_relative '../../base_module_client'
module Hubspot
module Discovery
module Cms
module AuditLogs
class Client
include Hubspot::Discovery::BaseModuleClient
def api_classes
%i[
audit_logs
].freeze
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/discovery/cms/audit_logs/api/audit_logs_api.rb | lib/hubspot/discovery/cms/audit_logs/api/audit_logs_api.rb | require_relative '../../../base_api_client'
module Hubspot
module Discovery
module Cms
module AuditLogs
class AuditLogsApi
include Hubspot::Discovery::BaseApiClient
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/discovery/cms/url_redirects/client.rb | lib/hubspot/discovery/cms/url_redirects/client.rb | require_relative '../../base_module_client'
module Hubspot
module Discovery
module Cms
module UrlRedirects
class Client
include Hubspot::Discovery::BaseModuleClient
def api_classes
%i[
redirects
].freeze
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/discovery/cms/url_redirects/api/redirects_api.rb | lib/hubspot/discovery/cms/url_redirects/api/redirects_api.rb | require_relative '../../../base_api_client'
module Hubspot
module Discovery
module Cms
module UrlRedirects
class RedirectsApi
include Hubspot::Discovery::BaseApiClient
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/discovery/cms/site_search/client.rb | lib/hubspot/discovery/cms/site_search/client.rb | require_relative '../../base_module_client'
module Hubspot
module Discovery
module Cms
module SiteSearch
class Client
include Hubspot::Discovery::BaseModuleClient
def api_classes
%i[
public
].freeze
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/discovery/cms/site_search/api/public_api.rb | lib/hubspot/discovery/cms/site_search/api/public_api.rb | require_relative '../../../base_api_client'
module Hubspot
module Discovery
module Cms
module SiteSearch
class PublicApi
include Hubspot::Discovery::BaseApiClient
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/discovery/cms/blogs/client.rb | lib/hubspot/discovery/cms/blogs/client.rb | require_relative '../../base_module_client'
module Hubspot
module Discovery
module Cms
module Blogs
class Client
include Hubspot::Discovery::BaseModuleClient
def api_modules
%i[
authors
blog_posts
tags
].freeze
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/discovery/cms/blogs/authors/client.rb | lib/hubspot/discovery/cms/blogs/authors/client.rb | require_relative '../../../base_module_client'
module Hubspot
module Discovery
module Cms
module Blogs
module Authors
class Client
include Hubspot::Discovery::BaseModuleClient
def api_classes
%i[
blog_authors
].freeze
end
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/discovery/cms/blogs/authors/api/blog_authors_api.rb | lib/hubspot/discovery/cms/blogs/authors/api/blog_authors_api.rb | require_relative '../../../../base_api_client'
module Hubspot
module Discovery
module Cms
module Blogs
module Authors
class BlogAuthorsApi
include Hubspot::Discovery::BaseApiClient
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/discovery/cms/blogs/blog_posts/client.rb | lib/hubspot/discovery/cms/blogs/blog_posts/client.rb | require_relative '../../../base_module_client'
module Hubspot
module Discovery
module Cms
module Blogs
module BlogPosts
class Client
include Hubspot::Discovery::BaseModuleClient
def api_classes
%i[
basic
batch
multi_language
].freeze
end
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/discovery/cms/blogs/blog_posts/api/multi_language_api.rb | lib/hubspot/discovery/cms/blogs/blog_posts/api/multi_language_api.rb | require_relative '../../../../base_api_client'
module Hubspot
module Discovery
module Cms
module Blogs
module BlogPosts
class MultiLanguageApi
include Hubspot::Discovery::BaseApiClient
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/discovery/cms/blogs/blog_posts/api/batch_api.rb | lib/hubspot/discovery/cms/blogs/blog_posts/api/batch_api.rb | require_relative '../../../../base_api_client'
module Hubspot
module Discovery
module Cms
module Blogs
module BlogPosts
class BatchApi
include Hubspot::Discovery::BaseApiClient
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/discovery/cms/blogs/blog_posts/api/basic_api.rb | lib/hubspot/discovery/cms/blogs/blog_posts/api/basic_api.rb | require_relative '../../../../base_api_client'
module Hubspot
module Discovery
module Cms
module Blogs
module BlogPosts
class BasicApi
include Hubspot::Discovery::BaseApiClient
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/discovery/cms/blogs/tags/client.rb | lib/hubspot/discovery/cms/blogs/tags/client.rb | require_relative '../../../base_module_client'
module Hubspot
module Discovery
module Cms
module Blogs
module Tags
class Client
include Hubspot::Discovery::BaseModuleClient
def api_classes
%i[
blog_tags
].freeze
end
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/discovery/cms/blogs/tags/api/blog_tags_api.rb | lib/hubspot/discovery/cms/blogs/tags/api/blog_tags_api.rb | require_relative '../../../../base_api_client'
module Hubspot
module Discovery
module Cms
module Blogs
module Tags
class BlogTagsApi
include Hubspot::Discovery::BaseApiClient
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/discovery/cms/pages/client.rb | lib/hubspot/discovery/cms/pages/client.rb | require_relative '../../base_module_client'
module Hubspot
module Discovery
module Cms
module Pages
class Client
include Hubspot::Discovery::BaseModuleClient
def api_classes
%i[
landing_pages
site_pages
].freeze
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/discovery/cms/pages/api/landing_pages_api.rb | lib/hubspot/discovery/cms/pages/api/landing_pages_api.rb | require_relative '../../../base_api_client'
module Hubspot
module Discovery
module Cms
module Pages
class LandingPagesApi
include Hubspot::Discovery::BaseApiClient
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/discovery/cms/pages/api/site_pages_api.rb | lib/hubspot/discovery/cms/pages/api/site_pages_api.rb | require_relative '../../../base_api_client'
module Hubspot
module Discovery
module Cms
module Pages
class SitePagesApi
include Hubspot::Discovery::BaseApiClient
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/discovery/cms/source_code/client.rb | lib/hubspot/discovery/cms/source_code/client.rb | require_relative '../../base_module_client'
module Hubspot
module Discovery
module Cms
module SourceCode
class Client
include Hubspot::Discovery::BaseModuleClient
def api_classes
%i[
content
extract
metadata
validation
].freeze
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/discovery/cms/source_code/api/metadata_api.rb | lib/hubspot/discovery/cms/source_code/api/metadata_api.rb | require_relative '../../../base_api_client'
module Hubspot
module Discovery
module Cms
module SourceCode
class MetadataApi
include Hubspot::Discovery::BaseApiClient
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/discovery/cms/source_code/api/validation_api.rb | lib/hubspot/discovery/cms/source_code/api/validation_api.rb | require_relative '../../../base_api_client'
module Hubspot
module Discovery
module Cms
module SourceCode
class ValidationApi
include Hubspot::Discovery::BaseApiClient
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/discovery/cms/source_code/api/content_api.rb | lib/hubspot/discovery/cms/source_code/api/content_api.rb | require_relative '../../../base_api_client'
module Hubspot
module Discovery
module Cms
module SourceCode
class ContentApi
include Hubspot::Discovery::BaseApiClient
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/discovery/cms/source_code/api/extract_api.rb | lib/hubspot/discovery/cms/source_code/api/extract_api.rb | require_relative '../../../base_api_client'
module Hubspot
module Discovery
module Cms
module SourceCode
class ExtractApi
include Hubspot::Discovery::BaseApiClient
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/discovery/cms/domains/client.rb | lib/hubspot/discovery/cms/domains/client.rb | require_relative '../../base_module_client'
module Hubspot
module Discovery
module Cms
module Domains
class Client
include Hubspot::Discovery::BaseModuleClient
def api_classes
%i[
domains
].freeze
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/discovery/cms/domains/api/domains_api.rb | lib/hubspot/discovery/cms/domains/api/domains_api.rb | require_relative '../../../base_api_client'
module Hubspot
module Discovery
module Cms
module Domains
class DomainsApi
include Hubspot::Discovery::BaseApiClient
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/discovery/cms/hubdb/client.rb | lib/hubspot/discovery/cms/hubdb/client.rb | require_relative '../../base_module_client'
module Hubspot
module Discovery
module Cms
module Hubdb
class Client
include Hubspot::Discovery::BaseModuleClient
def api_classes
%i[
rows
rows_batch
tables
].freeze
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/discovery/cms/hubdb/api/rows_api.rb | lib/hubspot/discovery/cms/hubdb/api/rows_api.rb | require_relative '../../../base_api_client'
module Hubspot
module Discovery
module Cms
module Hubdb
class RowsApi
include Hubspot::Discovery::BaseApiClient
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/discovery/cms/hubdb/api/rows_batch_api.rb | lib/hubspot/discovery/cms/hubdb/api/rows_batch_api.rb | require_relative '../../../base_api_client'
module Hubspot
module Discovery
module Cms
module Hubdb
class RowsBatchApi
include Hubspot::Discovery::BaseApiClient
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/discovery/cms/hubdb/api/tables_api.rb | lib/hubspot/discovery/cms/hubdb/api/tables_api.rb | require_relative '../../../base_api_client'
module Hubspot
module Discovery
module Cms
module Hubdb
class TablesApi
include Hubspot::Discovery::BaseApiClient
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/discovery/automation/client.rb | lib/hubspot/discovery/automation/client.rb | require_relative '../base_module_client'
module Hubspot
module Discovery
module Automation
class Client
include Hubspot::Discovery::BaseModuleClient
def api_modules
%i[
actions
].freeze
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/discovery/automation/actions/client.rb | lib/hubspot/discovery/automation/actions/client.rb | require_relative '../../base_module_client'
module Hubspot
module Discovery
module Automation
module Actions
class Client
include Hubspot::Discovery::BaseModuleClient
def api_classes
%i[
callbacks
definitions
functions
revisions
].freeze
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/discovery/automation/actions/api/definitions_api.rb | lib/hubspot/discovery/automation/actions/api/definitions_api.rb | require_relative '../../../base_api_client'
module Hubspot
module Discovery
module Automation
module Actions
class DefinitionsApi
include Hubspot::Discovery::BaseApiClient
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/discovery/automation/actions/api/functions_api.rb | lib/hubspot/discovery/automation/actions/api/functions_api.rb | require_relative '../../../base_api_client'
module Hubspot
module Discovery
module Automation
module Actions
class FunctionsApi
include Hubspot::Discovery::BaseApiClient
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/discovery/automation/actions/api/revisions_api.rb | lib/hubspot/discovery/automation/actions/api/revisions_api.rb | require_relative '../../../base_api_client'
module Hubspot
module Discovery
module Automation
module Actions
class RevisionsApi
include Hubspot::Discovery::BaseApiClient
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/discovery/automation/actions/api/callbacks_api.rb | lib/hubspot/discovery/automation/actions/api/callbacks_api.rb | require_relative '../../../base_api_client'
module Hubspot
module Discovery
module Automation
module Actions
class CallbacksApi
include Hubspot::Discovery::BaseApiClient
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/settings/users/api_error.rb | lib/hubspot/codegen/settings/users/api_error.rb | =begin
#User Provisioning
#Add, manage, and remove users from your account
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
module Hubspot
module Settings
module Users
class ApiError < ::StandardError
attr_reader :code, :response_headers, :response_body
# Usage examples:
# ApiError.new
# ApiError.new("message")
# ApiError.new(:code => 500, :response_headers => {}, :response_body => "")
# ApiError.new(:code => 404, :message => "Not Found")
def initialize(arg = nil)
if arg.is_a? Hash
if arg.key?(:message) || arg.key?('message')
super(arg[:message] || arg['message'])
else
super arg
end
arg.each do |k, v|
instance_variable_set "@#{k}", v
end
else
super arg
end
end
# Override to_s to display a friendly error message
def to_s
message
end
def message
if @message.nil?
msg = "Error message: the server returns an error"
else
msg = @message
end
msg += "\nHTTP status code: #{code}" if code
msg += "\nResponse headers: #{response_headers}" if response_headers
msg += "\nResponse body: #{response_body}" if response_body
msg
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/settings/users/configuration.rb | lib/hubspot/codegen/settings/users/configuration.rb | =begin
#User Provisioning
#Add, manage, and remove users from your account
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
module Hubspot
module Settings
module Users
class Configuration
# Defines url scheme
attr_accessor :scheme
# Defines url host
attr_accessor :host
# Defines url base path
attr_accessor :base_path
# Define server configuration index
attr_accessor :server_index
# Define server operation configuration index
attr_accessor :server_operation_index
# Default server variables
attr_accessor :server_variables
# Default server operation variables
attr_accessor :server_operation_variables
# Defines API keys used with API Key authentications.
#
# @return [Hash] key: parameter name, value: parameter value (API key)
#
# @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
# config.api_key['api_key'] = 'xxx'
attr_accessor :api_key
# Defines API key prefixes used with API Key authentications.
#
# @return [Hash] key: parameter name, value: API key prefix
#
# @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
# config.api_key_prefix['api_key'] = 'Token'
attr_accessor :api_key_prefix
# Defines the username used with HTTP basic authentication.
#
# @return [String]
attr_accessor :username
# Defines the password used with HTTP basic authentication.
#
# @return [String]
attr_accessor :password
# Defines the access token (Bearer) used with OAuth2.
attr_accessor :access_token
# Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
# details will be logged with `logger.debug` (see the `logger` attribute).
# Default to false.
#
# @return [true, false]
attr_accessor :debugging
# Defines the logger used for debugging.
# Default to `Rails.logger` (when in Rails) or logging to STDOUT.
#
# @return [#debug]
attr_accessor :logger
# Defines the temporary folder to store downloaded files
# (for API endpoints that have file response).
# Default to use `Tempfile`.
#
# @return [String]
attr_accessor :temp_folder_path
# The time limit for HTTP request in seconds.
# Default to 0 (never times out).
attr_accessor :timeout
# Set this to false to skip client side validation in the operation.
# Default to true.
# @return [true, false]
attr_accessor :client_side_validation
### TLS/SSL setting
# Set this to false to skip verifying SSL certificate when calling API from https server.
# Default to true.
#
# @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
#
# @return [true, false]
attr_accessor :verify_ssl
### TLS/SSL setting
# Set this to false to skip verifying SSL host name
# Default to true.
#
# @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
#
# @return [true, false]
attr_accessor :verify_ssl_host
### TLS/SSL setting
# Set this to customize the certificate file to verify the peer.
#
# @return [String] the path to the certificate file
#
# @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code:
# https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
attr_accessor :ssl_ca_cert
### TLS/SSL setting
# Client certificate file (for client certificate)
attr_accessor :cert_file
### TLS/SSL setting
# Client private key file (for client certificate)
attr_accessor :key_file
# Set this to customize parameters encoding of array parameter with multi collectionFormat.
# Default to nil.
#
# @see The params_encoding option of Ethon. Related source code:
# https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
attr_accessor :params_encoding
attr_accessor :inject_format
attr_accessor :force_ending_format
attr_accessor :error_handler
def initialize
@scheme = 'https'
@host = 'api.hubapi.com'
@base_path = ''
@server_index = 0
@server_operation_index = {}
@server_variables = {}
@server_operation_variables = {}
@api_key = {}
@api_key_prefix = {}
@client_side_validation = true
@verify_ssl = true
@verify_ssl_host = true
@cert_file = nil
@key_file = nil
@timeout = 0
@params_encoding = nil
@debugging = false
@inject_format = false
@force_ending_format = false
@logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
# error_handler params: { 'status_code': { max_retries: ..., seconds_delay: ... }, ... }
@error_handler = {}
yield(self) if block_given?
end
# The default Configuration object.
def self.default
@@default ||= Configuration.new
end
def configure
yield(self) if block_given?
end
def scheme=(scheme)
# remove :// from scheme
@scheme = scheme.sub(/:\/\//, '')
end
def host=(host)
# remove http(s):// and anything after a slash
@host = host.sub(/https?:\/\//, '').split('/').first
end
def base_path=(base_path)
# Add leading and trailing slashes to base_path
@base_path = "/#{base_path}".gsub(/\/+/, '/')
@base_path = '' if @base_path == '/'
end
# Returns base URL for specified operation based on server settings
def base_url(operation = nil)
index = server_operation_index.fetch(operation, server_index)
return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if index == nil
server_url(index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
end
# Gets API key (with prefix if set).
# @param [String] param_name the parameter name of API key auth
def api_key_with_prefix(param_name, param_alias = nil)
key = @api_key[param_name]
key = @api_key.fetch(param_alias, key) unless param_alias.nil?
if @api_key_prefix[param_name]
"#{@api_key_prefix[param_name]} #{key}"
else
key
end
end
# Gets Basic Auth token string
def basic_auth_token
'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
end
# Returns Auth Settings hash for api client.
def auth_settings
{
'oauth2' =>
{
type: 'oauth2',
in: 'header',
key: 'Authorization',
value: "Bearer #{access_token}"
},
}
end
# Returns an array of Server setting
def server_settings
[
{
url: "https://api.hubapi.com",
description: "No description provided",
}
]
end
def operation_server_settings
{
}
end
# Returns URL based on server settings
#
# @param index array index of the server settings
# @param variables hash of variable and the corresponding value
def server_url(index, variables = {}, servers = nil)
servers = server_settings if servers == nil
# check array index out of bound
if (index < 0 || index >= servers.size)
fail ArgumentError, "Invalid index #{index} when selecting the server. Must be less than #{servers.size}"
end
server = servers[index]
url = server[:url]
return url unless server.key? :variables
# go through variable and assign a value
server[:variables].each do |name, variable|
if variables.key?(name)
if (!server[:variables][name].key?(:enum_values) || server[:variables][name][:enum_values].include?(variables[name]))
url.gsub! "{" + name.to_s + "}", variables[name]
else
fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."
end
else
# use default value
url.gsub! "{" + name.to_s + "}", server[:variables][name][:default_value]
end
end
url
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/settings/users/api_client.rb | lib/hubspot/codegen/settings/users/api_client.rb | =begin
#User Provisioning
#Add, manage, and remove users from your account
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'json'
require 'logger'
require 'tempfile'
require 'time'
require 'typhoeus'
module Hubspot
module Settings
module Users
class ApiClient
# The Configuration object holding settings to be used in the API client.
attr_accessor :config
# Defines the headers to be used in HTTP requests of all API calls by default.
#
# @return [Hash]
attr_accessor :default_headers
# Initializes the ApiClient
# @option config [Configuration] Configuration for initializing the object, default to Configuration.default
def initialize(config = Configuration.default)
@config = config
@user_agent = "hubspot-api-client-ruby; #{VERSION}"
@default_headers = {
'Content-Type' => 'application/json',
'User-Agent' => @user_agent
}
end
def self.default
@@default ||= ApiClient.new
end
# Call an API with given options.
#
# @return [Array<(Object, Integer, Hash)>] an array of 3 elements:
# the data deserialized from response body (could be nil), response status code and response headers.
def call_api(http_method, path, opts = {})
request = build_request(http_method, path, opts)
response = request.run
if @config.debugging
@config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
end
if !response.success? && config.error_handler.any?
config.error_handler.each do |statuses, opts|
statuses = statuses.is_a?(Integer) ? [statuses] : statuses
retries = opts[:max_retries] || 5
while retries > 0 && statuses.include?(response.code)
sleep opts[:seconds_delay] if opts[:seconds_delay]
response = request.run
opts[:retry_block].call if opts[:retry_block]
retries -= 1
end
end
end
unless response.success?
if response.timed_out?
fail ApiError.new('Connection timed out')
elsif response.code == 0
# Errors from libcurl will be made visible here
fail ApiError.new(:code => 0,
:message => response.return_message)
else
fail ApiError.new(:code => response.code,
:response_headers => response.headers,
:response_body => response.body),
response.status_message
end
end
if opts[:return_type]
data = deserialize(response, opts[:return_type])
else
data = nil
end
return data, response.code, response.headers
end
# Builds the HTTP request
#
# @param [String] http_method HTTP method/verb (e.g. POST)
# @param [String] path URL path (e.g. /account/new)
# @option opts [Hash] :header_params Header parameters
# @option opts [Hash] :query_params Query parameters
# @option opts [Hash] :form_params Query parameters
# @option opts [Object] :body HTTP body (JSON/XML)
# @return [Typhoeus::Request] A Typhoeus Request
def build_request(http_method, path, opts = {})
url = build_request_url(path, opts)
http_method = http_method.to_sym.downcase
header_params = @default_headers.merge(opts[:header_params] || {})
query_params = opts[:query_params] || {}
form_params = opts[:form_params] || {}
follow_location = opts[:follow_location] || true
update_params_for_auth! header_params, query_params, opts[:auth_names]
# set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)
_verify_ssl_host = @config.verify_ssl_host ? 2 : 0
req_opts = {
:method => http_method,
:headers => header_params,
:params => query_params,
:params_encoding => @config.params_encoding,
:timeout => @config.timeout,
:ssl_verifypeer => @config.verify_ssl,
:ssl_verifyhost => _verify_ssl_host,
:sslcert => @config.cert_file,
:sslkey => @config.key_file,
:verbose => @config.debugging,
:followlocation => follow_location
}
# set custom cert, if provided
req_opts[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert
if [:post, :patch, :put, :delete].include?(http_method)
req_body = build_request_body(header_params, form_params, opts[:body])
req_opts.update :body => req_body
if @config.debugging
@config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n"
end
end
request = Typhoeus::Request.new(url, req_opts)
download_file(request) if opts[:return_type] == 'File'
request
end
# Builds the HTTP request body
#
# @param [Hash] header_params Header parameters
# @param [Hash] form_params Query parameters
# @param [Object] body HTTP body (JSON/XML)
# @return [String] HTTP body data in the form of string
def build_request_body(header_params, form_params, body)
# http form
if header_params['Content-Type'] == 'application/x-www-form-urlencoded' ||
header_params['Content-Type'] == 'multipart/form-data'
data = {}
form_params.each do |key, value|
case value
when ::File, ::Array, nil
# let typhoeus handle File, Array and nil parameters
data[key] = value
else
data[key] = value.to_s
end
end
elsif body
data = body.is_a?(String) ? body : body.to_json
else
data = nil
end
data
end
# Save response body into a file in (the defined) temporary folder, using the filename
# from the "Content-Disposition" header if provided, otherwise a random filename.
# The response body is written to the file in chunks in order to handle files which
# size is larger than maximum Ruby String or even larger than the maximum memory a Ruby
# process can use.
#
# @see Configuration#temp_folder_path
def download_file(request)
tempfile = nil
encoding = nil
request.on_headers do |response|
content_disposition = response.headers['Content-Disposition']
if content_disposition && content_disposition =~ /filename=/i
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
prefix = sanitize_filename(filename)
else
prefix = 'download-'
end
prefix = prefix + '-' unless prefix.end_with?('-')
encoding = response.body.encoding
tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
@tempfile = tempfile
end
request.on_body do |chunk|
chunk.force_encoding(encoding)
tempfile.write(chunk)
end
request.on_complete do |response|
if tempfile
tempfile.close
@config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
"will be deleted automatically with GC. It's also recommended to delete the temp file "\
"explicitly with `tempfile.delete`"
end
end
end
# Check if the given MIME is a JSON MIME.
# JSON MIME examples:
# application/json
# application/json; charset=UTF8
# APPLICATION/JSON
# */*
# @param [String] mime MIME
# @return [Boolean] True if the MIME is application/json
def json_mime?(mime)
(mime == '*/*') || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
end
# Deserialize the response to the given return type.
#
# @param [Response] response HTTP response
# @param [String] return_type some examples: "User", "Array<User>", "Hash<String, Integer>"
def deserialize(response, return_type)
body = response.body
# handle file downloading - return the File instance processed in request callbacks
# note that response body is empty when the file is written in chunks in request on_body callback
return @tempfile if return_type == 'File'
return nil if body.nil? || body.empty?
# return response body directly for String return type
return body if return_type == 'String'
# ensuring a default content type
content_type = response.headers['Content-Type'] || 'application/json'
fail "Content-Type is not supported: #{content_type}" unless json_mime?(content_type)
begin
data = JSON.parse("[#{body}]", :symbolize_names => true)[0]
rescue JSON::ParserError => e
if %w(String Date Time).include?(return_type)
data = body
else
raise e
end
end
convert_to_type data, return_type
end
# Convert data to the given return type.
# @param [Object] data Data to be converted
# @param [String] return_type Return type
# @return [Mixed] Data in a particular type
def convert_to_type(data, return_type)
return nil if data.nil?
case return_type
when 'String'
data.to_s
when 'Integer'
data.to_i
when 'Float'
data.to_f
when 'Boolean'
data == true
when 'Time'
# parse date time (expecting ISO 8601 format)
Time.parse data
when 'Date'
# parse date time (expecting ISO 8601 format)
Date.parse data
when 'Object'
# generic object (usually a Hash), return directly
data
when /\AArray<(.+)>\z/
# e.g. Array<Pet>
sub_type = $1
data.map { |item| convert_to_type(item, sub_type) }
when /\AHash\<String, (.+)\>\z/
# e.g. Hash<String, Integer>
sub_type = $1
{}.tap do |hash|
data.each { |k, v| hash[k] = convert_to_type(v, sub_type) }
end
else
# models (e.g. Pet) or oneOf
klass = Hubspot::Settings::Users.const_get(return_type)
klass.respond_to?(:openapi_one_of) ? klass.build(data) : klass.build_from_hash(data)
end
end
# Sanitize filename by removing path.
# e.g. ../../sun.gif becomes sun.gif
#
# @param [String] filename the filename to be sanitized
# @return [String] the sanitized filename
def sanitize_filename(filename)
filename.gsub(/.*[\/\\]/, '')
end
def build_request_url(path, opts = {})
# Add leading and trailing slashes to path
path = "/#{path}".gsub(/\/+/, '/')
@config.base_url(opts[:operation]) + path
end
# Update header and query params based on authentication settings.
#
# @param [Hash] header_params Header parameters
# @param [Hash] query_params Query parameters
# @param [String] auth_names Authentication scheme name
def update_params_for_auth!(header_params, query_params, auth_names)
Array(auth_names).each do |auth_name|
auth_setting = @config.auth_settings[auth_name]
next unless auth_setting
case auth_setting[:in]
when 'header' then header_params[auth_setting[:key]] = auth_setting[:value]
when 'query' then query_params[auth_setting[:key]] = auth_setting[:value]
else fail ArgumentError, 'Authentication token must be in `query` or `header`'
end
end
end
# Sets user agent in HTTP header
#
# @param [String] user_agent User agent (e.g. openapi-generator/ruby/1.0.0)
def user_agent=(user_agent)
@user_agent = user_agent
@default_headers['User-Agent'] = @user_agent
end
# Return Accept header based on an array of accepts provided.
# @param [Array] accepts array for Accept
# @return [String] the Accept header (e.g. application/json)
def select_header_accept(accepts)
return nil if accepts.nil? || accepts.empty?
# use JSON when present, otherwise use all of the provided
json_accept = accepts.find { |s| json_mime?(s) }
json_accept || accepts.join(',')
end
# Return Content-Type header based on an array of content types provided.
# @param [Array] content_types array for Content-Type
# @return [String] the Content-Type header (e.g. application/json)
def select_header_content_type(content_types)
# return nil by default
return if content_types.nil? || content_types.empty?
# use JSON when present, otherwise use the first one
json_content_type = content_types.find { |s| json_mime?(s) }
json_content_type || content_types.first
end
# Convert object (array, hash, object, etc) to JSON string.
# @param [Object] model object to be converted into JSON string
# @return [String] JSON string representation of the object
def object_to_http_body(model)
return model if model.nil? || model.is_a?(String)
local_body = nil
if model.is_a?(Array)
local_body = model.map { |m| object_to_hash(m) }
else
local_body = object_to_hash(model)
end
local_body.to_json
end
# Convert object(non-array) to hash.
# @param [Object] obj object to be converted into JSON string
# @return [String] JSON string representation of the object
def object_to_hash(obj)
if obj.respond_to?(:to_hash)
obj.to_hash
else
obj
end
end
# Build parameter value according to the given collection format.
# @param [String] collection_format one of :csv, :ssv, :tsv, :pipes and :multi
def build_collection_param(param, collection_format)
case collection_format
when :csv
param.join(',')
when :ssv
param.join(' ')
when :tsv
param.join("\t")
when :pipes
param.join('|')
when :multi
# return the array directly as typhoeus will handle it as expected
param
else
fail "unknown collection format: #{collection_format.inspect}"
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/settings/users/models/public_user_update.rb | lib/hubspot/codegen/settings/users/models/public_user_update.rb | =begin
#User Provisioning
#Add, manage, and remove users from your account
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Settings
module Users
# A user to update
class PublicUserUpdate
attr_accessor :first_name
attr_accessor :last_name
# The user's primary team
attr_accessor :primary_team_id
# The user's role
attr_accessor :role_id
# The user's additional teams
attr_accessor :secondary_team_ids
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'first_name' => :'firstName',
:'last_name' => :'lastName',
:'primary_team_id' => :'primaryTeamId',
:'role_id' => :'roleId',
:'secondary_team_ids' => :'secondaryTeamIds'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'first_name' => :'String',
:'last_name' => :'String',
:'primary_team_id' => :'String',
:'role_id' => :'String',
:'secondary_team_ids' => :'Array<String>'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Settings::Users::PublicUserUpdate` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Settings::Users::PublicUserUpdate`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'first_name')
self.first_name = attributes[:'first_name']
end
if attributes.key?(:'last_name')
self.last_name = attributes[:'last_name']
end
if attributes.key?(:'primary_team_id')
self.primary_team_id = attributes[:'primary_team_id']
end
if attributes.key?(:'role_id')
self.role_id = attributes[:'role_id']
end
if attributes.key?(:'secondary_team_ids')
if (value = attributes[:'secondary_team_ids']).is_a?(Array)
self.secondary_team_ids = value
end
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
first_name == o.first_name &&
last_name == o.last_name &&
primary_team_id == o.primary_team_id &&
role_id == o.role_id &&
secondary_team_ids == o.secondary_team_ids
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[first_name, last_name, primary_team_id, role_id, secondary_team_ids].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Settings::Users.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/settings/users/models/user_provision_request.rb | lib/hubspot/codegen/settings/users/models/user_provision_request.rb | =begin
#User Provisioning
#Add, manage, and remove users from your account
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Settings
module Users
# A user creation request
class UserProvisionRequest
attr_accessor :first_name
attr_accessor :last_name
# The user's primary team
attr_accessor :primary_team_id
# Whether to send a welcome email
attr_accessor :send_welcome_email
# The user's role
attr_accessor :role_id
# The user's additional teams
attr_accessor :secondary_team_ids
# The created user's email
attr_accessor :email
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'first_name' => :'firstName',
:'last_name' => :'lastName',
:'primary_team_id' => :'primaryTeamId',
:'send_welcome_email' => :'sendWelcomeEmail',
:'role_id' => :'roleId',
:'secondary_team_ids' => :'secondaryTeamIds',
:'email' => :'email'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'first_name' => :'String',
:'last_name' => :'String',
:'primary_team_id' => :'String',
:'send_welcome_email' => :'Boolean',
:'role_id' => :'String',
:'secondary_team_ids' => :'Array<String>',
:'email' => :'String'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Settings::Users::UserProvisionRequest` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Settings::Users::UserProvisionRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'first_name')
self.first_name = attributes[:'first_name']
end
if attributes.key?(:'last_name')
self.last_name = attributes[:'last_name']
end
if attributes.key?(:'primary_team_id')
self.primary_team_id = attributes[:'primary_team_id']
end
if attributes.key?(:'send_welcome_email')
self.send_welcome_email = attributes[:'send_welcome_email']
end
if attributes.key?(:'role_id')
self.role_id = attributes[:'role_id']
end
if attributes.key?(:'secondary_team_ids')
if (value = attributes[:'secondary_team_ids']).is_a?(Array)
self.secondary_team_ids = value
end
end
if attributes.key?(:'email')
self.email = attributes[:'email']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @email.nil?
invalid_properties.push('invalid value for "email", email cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @email.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
first_name == o.first_name &&
last_name == o.last_name &&
primary_team_id == o.primary_team_id &&
send_welcome_email == o.send_welcome_email &&
role_id == o.role_id &&
secondary_team_ids == o.secondary_team_ids &&
email == o.email
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[first_name, last_name, primary_team_id, send_welcome_email, role_id, secondary_team_ids, email].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Settings::Users.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/settings/users/models/next_page.rb | lib/hubspot/codegen/settings/users/models/next_page.rb | =begin
#User Provisioning
#Add, manage, and remove users from your account
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Settings
module Users
class NextPage
attr_accessor :link
attr_accessor :after
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'link' => :'link',
:'after' => :'after'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'link' => :'String',
:'after' => :'String'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Settings::Users::NextPage` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Settings::Users::NextPage`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'link')
self.link = attributes[:'link']
end
if attributes.key?(:'after')
self.after = attributes[:'after']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @after.nil?
invalid_properties.push('invalid value for "after", after cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @after.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
link == o.link &&
after == o.after
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[link, after].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Settings::Users.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/settings/users/models/collection_response_public_user_forward_paging.rb | lib/hubspot/codegen/settings/users/models/collection_response_public_user_forward_paging.rb | =begin
#User Provisioning
#Add, manage, and remove users from your account
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Settings
module Users
class CollectionResponsePublicUserForwardPaging
attr_accessor :paging
attr_accessor :results
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'paging' => :'paging',
:'results' => :'results'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'paging' => :'ForwardPaging',
:'results' => :'Array<PublicUser>'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Settings::Users::CollectionResponsePublicUserForwardPaging` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Settings::Users::CollectionResponsePublicUserForwardPaging`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'paging')
self.paging = attributes[:'paging']
end
if attributes.key?(:'results')
if (value = attributes[:'results']).is_a?(Array)
self.results = value
end
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @results.nil?
invalid_properties.push('invalid value for "results", results cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @results.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
paging == o.paging &&
results == o.results
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[paging, results].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Settings::Users.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/settings/users/models/public_user.rb | lib/hubspot/codegen/settings/users/models/public_user.rb | =begin
#User Provisioning
#Add, manage, and remove users from your account
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Settings
module Users
# A user
class PublicUser
attr_accessor :first_name
attr_accessor :last_name
# The user's primary team
attr_accessor :primary_team_id
attr_accessor :role_ids
attr_accessor :send_welcome_email
# The user's role
attr_accessor :role_id
# The user's additional teams
attr_accessor :secondary_team_ids
# The user's unique ID
attr_accessor :id
attr_accessor :super_admin
# The user's email
attr_accessor :email
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'first_name' => :'firstName',
:'last_name' => :'lastName',
:'primary_team_id' => :'primaryTeamId',
:'role_ids' => :'roleIds',
:'send_welcome_email' => :'sendWelcomeEmail',
:'role_id' => :'roleId',
:'secondary_team_ids' => :'secondaryTeamIds',
:'id' => :'id',
:'super_admin' => :'superAdmin',
:'email' => :'email'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'first_name' => :'String',
:'last_name' => :'String',
:'primary_team_id' => :'String',
:'role_ids' => :'Array<String>',
:'send_welcome_email' => :'Boolean',
:'role_id' => :'String',
:'secondary_team_ids' => :'Array<String>',
:'id' => :'String',
:'super_admin' => :'Boolean',
:'email' => :'String'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Settings::Users::PublicUser` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Settings::Users::PublicUser`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'first_name')
self.first_name = attributes[:'first_name']
end
if attributes.key?(:'last_name')
self.last_name = attributes[:'last_name']
end
if attributes.key?(:'primary_team_id')
self.primary_team_id = attributes[:'primary_team_id']
end
if attributes.key?(:'role_ids')
if (value = attributes[:'role_ids']).is_a?(Array)
self.role_ids = value
end
end
if attributes.key?(:'send_welcome_email')
self.send_welcome_email = attributes[:'send_welcome_email']
end
if attributes.key?(:'role_id')
self.role_id = attributes[:'role_id']
end
if attributes.key?(:'secondary_team_ids')
if (value = attributes[:'secondary_team_ids']).is_a?(Array)
self.secondary_team_ids = value
end
end
if attributes.key?(:'id')
self.id = attributes[:'id']
end
if attributes.key?(:'super_admin')
self.super_admin = attributes[:'super_admin']
end
if attributes.key?(:'email')
self.email = attributes[:'email']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @id.nil?
invalid_properties.push('invalid value for "id", id cannot be nil.')
end
if @email.nil?
invalid_properties.push('invalid value for "email", email cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @id.nil?
return false if @email.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
first_name == o.first_name &&
last_name == o.last_name &&
primary_team_id == o.primary_team_id &&
role_ids == o.role_ids &&
send_welcome_email == o.send_welcome_email &&
role_id == o.role_id &&
secondary_team_ids == o.secondary_team_ids &&
id == o.id &&
super_admin == o.super_admin &&
email == o.email
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[first_name, last_name, primary_team_id, role_ids, send_welcome_email, role_id, secondary_team_ids, id, super_admin, email].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Settings::Users.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/settings/users/models/error_detail.rb | lib/hubspot/codegen/settings/users/models/error_detail.rb | =begin
#User Provisioning
#Add, manage, and remove users from your account
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Settings
module Users
class ErrorDetail
# A specific category that contains more specific detail about the error
attr_accessor :sub_category
# The status code associated with the error detail
attr_accessor :code
# The name of the field or parameter in which the error was found.
attr_accessor :_in
# Context about the error condition
attr_accessor :context
# A human readable message describing the error along with remediation steps where appropriate
attr_accessor :message
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'sub_category' => :'subCategory',
:'code' => :'code',
:'_in' => :'in',
:'context' => :'context',
:'message' => :'message'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'sub_category' => :'String',
:'code' => :'String',
:'_in' => :'String',
:'context' => :'Hash<String, Array<String>>',
:'message' => :'String'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Settings::Users::ErrorDetail` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Settings::Users::ErrorDetail`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'sub_category')
self.sub_category = attributes[:'sub_category']
end
if attributes.key?(:'code')
self.code = attributes[:'code']
end
if attributes.key?(:'_in')
self._in = attributes[:'_in']
end
if attributes.key?(:'context')
if (value = attributes[:'context']).is_a?(Hash)
self.context = value
end
end
if attributes.key?(:'message')
self.message = attributes[:'message']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @message.nil?
invalid_properties.push('invalid value for "message", message cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @message.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
sub_category == o.sub_category &&
code == o.code &&
_in == o._in &&
context == o.context &&
message == o.message
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[sub_category, code, _in, context, message].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Settings::Users.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/settings/users/models/collection_response_public_team_no_paging.rb | lib/hubspot/codegen/settings/users/models/collection_response_public_team_no_paging.rb | =begin
#User Provisioning
#Add, manage, and remove users from your account
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Settings
module Users
class CollectionResponsePublicTeamNoPaging
attr_accessor :results
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'results' => :'results'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'results' => :'Array<PublicTeam>'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Settings::Users::CollectionResponsePublicTeamNoPaging` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Settings::Users::CollectionResponsePublicTeamNoPaging`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'results')
if (value = attributes[:'results']).is_a?(Array)
self.results = value
end
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @results.nil?
invalid_properties.push('invalid value for "results", results cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @results.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
results == o.results
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[results].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Settings::Users.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/settings/users/models/forward_paging.rb | lib/hubspot/codegen/settings/users/models/forward_paging.rb | =begin
#User Provisioning
#Add, manage, and remove users from your account
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Settings
module Users
class ForwardPaging
attr_accessor :_next
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'_next' => :'next'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'_next' => :'NextPage'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Settings::Users::ForwardPaging` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Settings::Users::ForwardPaging`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'_next')
self._next = attributes[:'_next']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
_next == o._next
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[_next].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Settings::Users.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/settings/users/models/collection_response_public_permission_set_no_paging.rb | lib/hubspot/codegen/settings/users/models/collection_response_public_permission_set_no_paging.rb | =begin
#User Provisioning
#Add, manage, and remove users from your account
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Settings
module Users
class CollectionResponsePublicPermissionSetNoPaging
attr_accessor :results
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'results' => :'results'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'results' => :'Array<PublicPermissionSet>'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Settings::Users::CollectionResponsePublicPermissionSetNoPaging` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Settings::Users::CollectionResponsePublicPermissionSetNoPaging`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'results')
if (value = attributes[:'results']).is_a?(Array)
self.results = value
end
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @results.nil?
invalid_properties.push('invalid value for "results", results cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @results.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
results == o.results
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[results].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Settings::Users.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/settings/users/models/public_team.rb | lib/hubspot/codegen/settings/users/models/public_team.rb | =begin
#User Provisioning
#Add, manage, and remove users from your account
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Settings
module Users
# A team that can be assigned to a user
class PublicTeam
# Primary members of this team
attr_accessor :user_ids
# The team's name
attr_accessor :name
# The team's unique ID
attr_accessor :id
# Secondary or additional members of this team
attr_accessor :secondary_user_ids
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'user_ids' => :'userIds',
:'name' => :'name',
:'id' => :'id',
:'secondary_user_ids' => :'secondaryUserIds'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'user_ids' => :'Array<String>',
:'name' => :'String',
:'id' => :'String',
:'secondary_user_ids' => :'Array<String>'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Settings::Users::PublicTeam` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Settings::Users::PublicTeam`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'user_ids')
if (value = attributes[:'user_ids']).is_a?(Array)
self.user_ids = value
end
end
if attributes.key?(:'name')
self.name = attributes[:'name']
end
if attributes.key?(:'id')
self.id = attributes[:'id']
end
if attributes.key?(:'secondary_user_ids')
if (value = attributes[:'secondary_user_ids']).is_a?(Array)
self.secondary_user_ids = value
end
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @user_ids.nil?
invalid_properties.push('invalid value for "user_ids", user_ids cannot be nil.')
end
if @name.nil?
invalid_properties.push('invalid value for "name", name cannot be nil.')
end
if @id.nil?
invalid_properties.push('invalid value for "id", id cannot be nil.')
end
if @secondary_user_ids.nil?
invalid_properties.push('invalid value for "secondary_user_ids", secondary_user_ids cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @user_ids.nil?
return false if @name.nil?
return false if @id.nil?
return false if @secondary_user_ids.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
user_ids == o.user_ids &&
name == o.name &&
id == o.id &&
secondary_user_ids == o.secondary_user_ids
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[user_ids, name, id, secondary_user_ids].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Settings::Users.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/settings/users/models/public_permission_set.rb | lib/hubspot/codegen/settings/users/models/public_permission_set.rb | =begin
#User Provisioning
#Add, manage, and remove users from your account
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Settings
module Users
# A role that can be assigned to a user
class PublicPermissionSet
# Whether this role has a paid seat and requires the billing-write scope to assign/unassign to users
attr_accessor :requires_billing_write
# The role's name
attr_accessor :name
# The role's unique ID
attr_accessor :id
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'requires_billing_write' => :'requiresBillingWrite',
:'name' => :'name',
:'id' => :'id'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'requires_billing_write' => :'Boolean',
:'name' => :'String',
:'id' => :'String'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Settings::Users::PublicPermissionSet` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Settings::Users::PublicPermissionSet`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'requires_billing_write')
self.requires_billing_write = attributes[:'requires_billing_write']
end
if attributes.key?(:'name')
self.name = attributes[:'name']
end
if attributes.key?(:'id')
self.id = attributes[:'id']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @requires_billing_write.nil?
invalid_properties.push('invalid value for "requires_billing_write", requires_billing_write cannot be nil.')
end
if @name.nil?
invalid_properties.push('invalid value for "name", name cannot be nil.')
end
if @id.nil?
invalid_properties.push('invalid value for "id", id cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @requires_billing_write.nil?
return false if @name.nil?
return false if @id.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
requires_billing_write == o.requires_billing_write &&
name == o.name &&
id == o.id
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[requires_billing_write, name, id].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Settings::Users.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/settings/users/models/error.rb | lib/hubspot/codegen/settings/users/models/error.rb | =begin
#User Provisioning
#Add, manage, and remove users from your account
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Settings
module Users
class Error
# A specific category that contains more specific detail about the error
attr_accessor :sub_category
# Context about the error condition
attr_accessor :context
# A unique identifier for the request. Include this value with any error reports or support tickets
attr_accessor :correlation_id
# A map of link names to associated URIs containing documentation about the error or recommended remediation steps
attr_accessor :links
# A human readable message describing the error along with remediation steps where appropriate
attr_accessor :message
# The error category
attr_accessor :category
# further information about the error
attr_accessor :errors
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'sub_category' => :'subCategory',
:'context' => :'context',
:'correlation_id' => :'correlationId',
:'links' => :'links',
:'message' => :'message',
:'category' => :'category',
:'errors' => :'errors'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'sub_category' => :'String',
:'context' => :'Hash<String, Array<String>>',
:'correlation_id' => :'String',
:'links' => :'Hash<String, String>',
:'message' => :'String',
:'category' => :'String',
:'errors' => :'Array<ErrorDetail>'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Settings::Users::Error` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Settings::Users::Error`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'sub_category')
self.sub_category = attributes[:'sub_category']
end
if attributes.key?(:'context')
if (value = attributes[:'context']).is_a?(Hash)
self.context = value
end
end
if attributes.key?(:'correlation_id')
self.correlation_id = attributes[:'correlation_id']
end
if attributes.key?(:'links')
if (value = attributes[:'links']).is_a?(Hash)
self.links = value
end
end
if attributes.key?(:'message')
self.message = attributes[:'message']
end
if attributes.key?(:'category')
self.category = attributes[:'category']
end
if attributes.key?(:'errors')
if (value = attributes[:'errors']).is_a?(Array)
self.errors = value
end
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @correlation_id.nil?
invalid_properties.push('invalid value for "correlation_id", correlation_id cannot be nil.')
end
if @message.nil?
invalid_properties.push('invalid value for "message", message cannot be nil.')
end
if @category.nil?
invalid_properties.push('invalid value for "category", category cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @correlation_id.nil?
return false if @message.nil?
return false if @category.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
sub_category == o.sub_category &&
context == o.context &&
correlation_id == o.correlation_id &&
links == o.links &&
message == o.message &&
category == o.category &&
errors == o.errors
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[sub_category, context, correlation_id, links, message, category, errors].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Settings::Users.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/settings/users/api/teams_api.rb | lib/hubspot/codegen/settings/users/api/teams_api.rb | =begin
#User Provisioning
#Add, manage, and remove users from your account
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'cgi'
module Hubspot
module Settings
module Users
class TeamsApi
attr_accessor :api_client
def initialize(api_client = ApiClient.default)
@api_client = api_client
end
# See details about this account's teams
# View teams for this account
# @param [Hash] opts the optional parameters
# @return [CollectionResponsePublicTeamNoPaging]
def get_all(opts = {})
data, _status_code, _headers = get_all_with_http_info(opts)
data
end
# See details about this account's teams
# View teams for this account
# @param [Hash] opts the optional parameters
# @return [Array<(CollectionResponsePublicTeamNoPaging, Integer, Hash)>] CollectionResponsePublicTeamNoPaging data, response status code and response headers
def get_all_with_http_info(opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: TeamsApi.get_all ...'
end
# resource path
local_var_path = '/settings/v3/users/teams'
# query parameters
query_params = opts[:query_params] || {}
# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body]
# return_type
return_type = opts[:debug_return_type] || 'CollectionResponsePublicTeamNoPaging'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"TeamsApi.get_all",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: TeamsApi#get_all\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/settings/users/api/roles_api.rb | lib/hubspot/codegen/settings/users/api/roles_api.rb | =begin
#User Provisioning
#Add, manage, and remove users from your account
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'cgi'
module Hubspot
module Settings
module Users
class RolesApi
attr_accessor :api_client
def initialize(api_client = ApiClient.default)
@api_client = api_client
end
# Retrieves the roles on an account
# Retrieves the roles on an account
# @param [Hash] opts the optional parameters
# @return [CollectionResponsePublicPermissionSetNoPaging]
def get_all(opts = {})
data, _status_code, _headers = get_all_with_http_info(opts)
data
end
# Retrieves the roles on an account
# Retrieves the roles on an account
# @param [Hash] opts the optional parameters
# @return [Array<(CollectionResponsePublicPermissionSetNoPaging, Integer, Hash)>] CollectionResponsePublicPermissionSetNoPaging data, response status code and response headers
def get_all_with_http_info(opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: RolesApi.get_all ...'
end
# resource path
local_var_path = '/settings/v3/users/roles'
# query parameters
query_params = opts[:query_params] || {}
# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body]
# return_type
return_type = opts[:debug_return_type] || 'CollectionResponsePublicPermissionSetNoPaging'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"RolesApi.get_all",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: RolesApi#get_all\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/settings/users/api/users_api.rb | lib/hubspot/codegen/settings/users/api/users_api.rb | =begin
#User Provisioning
#Add, manage, and remove users from your account
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'cgi'
module Hubspot
module Settings
module Users
class UsersApi
attr_accessor :api_client
def initialize(api_client = ApiClient.default)
@api_client = api_client
end
# Removes a user
# Removes a user identified by `userId`. `userId` refers to the user's ID by default, or optionally email as specified by the `IdProperty` query param.
# @param user_id [String] Identifier of user to delete
# @param [Hash] opts the optional parameters
# @option opts [String] :id_property The name of a property with unique user values. Valid values are `USER_ID`(default) or `EMAIL`
# @return [nil]
def archive(user_id, opts = {})
archive_with_http_info(user_id, opts)
nil
end
# Removes a user
# Removes a user identified by `userId`. `userId` refers to the user's ID by default, or optionally email as specified by the `IdProperty` query param.
# @param user_id [String] Identifier of user to delete
# @param [Hash] opts the optional parameters
# @option opts [String] :id_property The name of a property with unique user values. Valid values are `USER_ID`(default) or `EMAIL`
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
def archive_with_http_info(user_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: UsersApi.archive ...'
end
# verify the required parameter 'user_id' is set
if @api_client.config.client_side_validation && user_id.nil?
fail ArgumentError, "Missing the required parameter 'user_id' when calling UsersApi.archive"
end
allowable_values = ["USER_ID", "EMAIL"]
if @api_client.config.client_side_validation && opts[:'id_property'] && !allowable_values.include?(opts[:'id_property'])
fail ArgumentError, "invalid value for \"id_property\", must be one of #{allowable_values}"
end
# resource path
local_var_path = '/settings/v3/users/{userId}'.sub('{' + 'userId' + '}', CGI.escape(user_id.to_s))
# query parameters
query_params = opts[:query_params] || {}
query_params[:'idProperty'] = opts[:'id_property'] if !opts[:'id_property'].nil?
# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['*/*'])
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body]
# return_type
return_type = opts[:debug_return_type]
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"UsersApi.archive",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: UsersApi#archive\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Adds a user
# New users will only have minimal permissions, which is contacts-base. A welcome email will prompt them to set a password and log in to HubSpot.
# @param user_provision_request [UserProvisionRequest]
# @param [Hash] opts the optional parameters
# @return [PublicUser]
def create(user_provision_request, opts = {})
data, _status_code, _headers = create_with_http_info(user_provision_request, opts)
data
end
# Adds a user
# New users will only have minimal permissions, which is contacts-base. A welcome email will prompt them to set a password and log in to HubSpot.
# @param user_provision_request [UserProvisionRequest]
# @param [Hash] opts the optional parameters
# @return [Array<(PublicUser, Integer, Hash)>] PublicUser data, response status code and response headers
def create_with_http_info(user_provision_request, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: UsersApi.create ...'
end
# verify the required parameter 'user_provision_request' is set
if @api_client.config.client_side_validation && user_provision_request.nil?
fail ArgumentError, "Missing the required parameter 'user_provision_request' when calling UsersApi.create"
end
# resource path
local_var_path = '/settings/v3/users/'
# query parameters
query_params = opts[:query_params] || {}
# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])
# HTTP header 'Content-Type'
content_type = @api_client.select_header_content_type(['application/json'])
if !content_type.nil?
header_params['Content-Type'] = content_type
end
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body] || @api_client.object_to_http_body(user_provision_request)
# return_type
return_type = opts[:debug_return_type] || 'PublicUser'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"UsersApi.create",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: UsersApi#create\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Retrieves a user
# Retrieves a user identified by `userId`. `userId` refers to the user's ID by default, or optionally email as specified by the `IdProperty` query param.
# @param user_id [String] Identifier of user to retrieve
# @param [Hash] opts the optional parameters
# @option opts [String] :id_property The name of a property with unique user values. Valid values are `USER_ID`(default) or `EMAIL`
# @return [PublicUser]
def get_by_id(user_id, opts = {})
data, _status_code, _headers = get_by_id_with_http_info(user_id, opts)
data
end
# Retrieves a user
# Retrieves a user identified by `userId`. `userId` refers to the user's ID by default, or optionally email as specified by the `IdProperty` query param.
# @param user_id [String] Identifier of user to retrieve
# @param [Hash] opts the optional parameters
# @option opts [String] :id_property The name of a property with unique user values. Valid values are `USER_ID`(default) or `EMAIL`
# @return [Array<(PublicUser, Integer, Hash)>] PublicUser data, response status code and response headers
def get_by_id_with_http_info(user_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: UsersApi.get_by_id ...'
end
# verify the required parameter 'user_id' is set
if @api_client.config.client_side_validation && user_id.nil?
fail ArgumentError, "Missing the required parameter 'user_id' when calling UsersApi.get_by_id"
end
allowable_values = ["USER_ID", "EMAIL"]
if @api_client.config.client_side_validation && opts[:'id_property'] && !allowable_values.include?(opts[:'id_property'])
fail ArgumentError, "invalid value for \"id_property\", must be one of #{allowable_values}"
end
# resource path
local_var_path = '/settings/v3/users/{userId}'.sub('{' + 'userId' + '}', CGI.escape(user_id.to_s))
# query parameters
query_params = opts[:query_params] || {}
query_params[:'idProperty'] = opts[:'id_property'] if !opts[:'id_property'].nil?
# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body]
# return_type
return_type = opts[:debug_return_type] || 'PublicUser'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"UsersApi.get_by_id",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: UsersApi#get_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Retrieves a list of users from an account
# Retrieves a list of users from an account
# @param [Hash] opts the optional parameters
# @option opts [Integer] :limit The number of users to retrieve
# @option opts [String] :after Results will display maximum 100 users per page. Additional results will be on the next page.
# @return [CollectionResponsePublicUserForwardPaging]
def get_page(opts = {})
data, _status_code, _headers = get_page_with_http_info(opts)
data
end
# Retrieves a list of users from an account
# Retrieves a list of users from an account
# @param [Hash] opts the optional parameters
# @option opts [Integer] :limit The number of users to retrieve
# @option opts [String] :after Results will display maximum 100 users per page. Additional results will be on the next page.
# @return [Array<(CollectionResponsePublicUserForwardPaging, Integer, Hash)>] CollectionResponsePublicUserForwardPaging data, response status code and response headers
def get_page_with_http_info(opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: UsersApi.get_page ...'
end
# resource path
local_var_path = '/settings/v3/users/'
# query parameters
query_params = opts[:query_params] || {}
query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
query_params[:'after'] = opts[:'after'] if !opts[:'after'].nil?
# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body]
# return_type
return_type = opts[:debug_return_type] || 'CollectionResponsePublicUserForwardPaging'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"UsersApi.get_page",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: UsersApi#get_page\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Modifies a user
# Modifies a user identified by `userId`. `userId` refers to the user's ID by default, or optionally email as specified by the `IdProperty` query param.
# @param user_id [String] Identifier of user to retrieve
# @param public_user_update [PublicUserUpdate]
# @param [Hash] opts the optional parameters
# @option opts [String] :id_property The name of a property with unique user values. Valid values are `USER_ID`(default) or `EMAIL`
# @return [PublicUser]
def replace(user_id, public_user_update, opts = {})
data, _status_code, _headers = replace_with_http_info(user_id, public_user_update, opts)
data
end
# Modifies a user
# Modifies a user identified by `userId`. `userId` refers to the user's ID by default, or optionally email as specified by the `IdProperty` query param.
# @param user_id [String] Identifier of user to retrieve
# @param public_user_update [PublicUserUpdate]
# @param [Hash] opts the optional parameters
# @option opts [String] :id_property The name of a property with unique user values. Valid values are `USER_ID`(default) or `EMAIL`
# @return [Array<(PublicUser, Integer, Hash)>] PublicUser data, response status code and response headers
def replace_with_http_info(user_id, public_user_update, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: UsersApi.replace ...'
end
# verify the required parameter 'user_id' is set
if @api_client.config.client_side_validation && user_id.nil?
fail ArgumentError, "Missing the required parameter 'user_id' when calling UsersApi.replace"
end
# verify the required parameter 'public_user_update' is set
if @api_client.config.client_side_validation && public_user_update.nil?
fail ArgumentError, "Missing the required parameter 'public_user_update' when calling UsersApi.replace"
end
allowable_values = ["USER_ID", "EMAIL"]
if @api_client.config.client_side_validation && opts[:'id_property'] && !allowable_values.include?(opts[:'id_property'])
fail ArgumentError, "invalid value for \"id_property\", must be one of #{allowable_values}"
end
# resource path
local_var_path = '/settings/v3/users/{userId}'.sub('{' + 'userId' + '}', CGI.escape(user_id.to_s))
# query parameters
query_params = opts[:query_params] || {}
query_params[:'idProperty'] = opts[:'id_property'] if !opts[:'id_property'].nil?
# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])
# HTTP header 'Content-Type'
content_type = @api_client.select_header_content_type(['application/json'])
if !content_type.nil?
header_params['Content-Type'] = content_type
end
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body] || @api_client.object_to_http_body(public_user_update)
# return_type
return_type = opts[:debug_return_type] || 'PublicUser'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"UsersApi.replace",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: UsersApi#replace\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/settings/business_units/api_error.rb | lib/hubspot/codegen/settings/business_units/api_error.rb | =begin
#Business Units
#Retrieve Business Unit information.
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
module Hubspot
module Settings
module BusinessUnits
class ApiError < ::StandardError
attr_reader :code, :response_headers, :response_body
# Usage examples:
# ApiError.new
# ApiError.new("message")
# ApiError.new(:code => 500, :response_headers => {}, :response_body => "")
# ApiError.new(:code => 404, :message => "Not Found")
def initialize(arg = nil)
if arg.is_a? Hash
if arg.key?(:message) || arg.key?('message')
super(arg[:message] || arg['message'])
else
super arg
end
arg.each do |k, v|
instance_variable_set "@#{k}", v
end
else
super arg
end
end
# Override to_s to display a friendly error message
def to_s
message
end
def message
if @message.nil?
msg = "Error message: the server returns an error"
else
msg = @message
end
msg += "\nHTTP status code: #{code}" if code
msg += "\nResponse headers: #{response_headers}" if response_headers
msg += "\nResponse body: #{response_body}" if response_body
msg
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/settings/business_units/configuration.rb | lib/hubspot/codegen/settings/business_units/configuration.rb | =begin
#Business Units
#Retrieve Business Unit information.
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
module Hubspot
module Settings
module BusinessUnits
class Configuration
# Defines url scheme
attr_accessor :scheme
# Defines url host
attr_accessor :host
# Defines url base path
attr_accessor :base_path
# Define server configuration index
attr_accessor :server_index
# Define server operation configuration index
attr_accessor :server_operation_index
# Default server variables
attr_accessor :server_variables
# Default server operation variables
attr_accessor :server_operation_variables
# Defines API keys used with API Key authentications.
#
# @return [Hash] key: parameter name, value: parameter value (API key)
#
# @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
# config.api_key['api_key'] = 'xxx'
attr_accessor :api_key
# Defines API key prefixes used with API Key authentications.
#
# @return [Hash] key: parameter name, value: API key prefix
#
# @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
# config.api_key_prefix['api_key'] = 'Token'
attr_accessor :api_key_prefix
# Defines the username used with HTTP basic authentication.
#
# @return [String]
attr_accessor :username
# Defines the password used with HTTP basic authentication.
#
# @return [String]
attr_accessor :password
# Defines the access token (Bearer) used with OAuth2.
attr_accessor :access_token
# Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
# details will be logged with `logger.debug` (see the `logger` attribute).
# Default to false.
#
# @return [true, false]
attr_accessor :debugging
# Defines the logger used for debugging.
# Default to `Rails.logger` (when in Rails) or logging to STDOUT.
#
# @return [#debug]
attr_accessor :logger
# Defines the temporary folder to store downloaded files
# (for API endpoints that have file response).
# Default to use `Tempfile`.
#
# @return [String]
attr_accessor :temp_folder_path
# The time limit for HTTP request in seconds.
# Default to 0 (never times out).
attr_accessor :timeout
# Set this to false to skip client side validation in the operation.
# Default to true.
# @return [true, false]
attr_accessor :client_side_validation
### TLS/SSL setting
# Set this to false to skip verifying SSL certificate when calling API from https server.
# Default to true.
#
# @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
#
# @return [true, false]
attr_accessor :verify_ssl
### TLS/SSL setting
# Set this to false to skip verifying SSL host name
# Default to true.
#
# @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
#
# @return [true, false]
attr_accessor :verify_ssl_host
### TLS/SSL setting
# Set this to customize the certificate file to verify the peer.
#
# @return [String] the path to the certificate file
#
# @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code:
# https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
attr_accessor :ssl_ca_cert
### TLS/SSL setting
# Client certificate file (for client certificate)
attr_accessor :cert_file
### TLS/SSL setting
# Client private key file (for client certificate)
attr_accessor :key_file
# Set this to customize parameters encoding of array parameter with multi collectionFormat.
# Default to nil.
#
# @see The params_encoding option of Ethon. Related source code:
# https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
attr_accessor :params_encoding
attr_accessor :inject_format
attr_accessor :force_ending_format
attr_accessor :error_handler
def initialize
@scheme = 'https'
@host = 'api.hubapi.com'
@base_path = ''
@server_index = 0
@server_operation_index = {}
@server_variables = {}
@server_operation_variables = {}
@api_key = {}
@api_key_prefix = {}
@client_side_validation = true
@verify_ssl = true
@verify_ssl_host = true
@cert_file = nil
@key_file = nil
@timeout = 0
@params_encoding = nil
@debugging = false
@inject_format = false
@force_ending_format = false
@logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
# error_handler params: { 'status_code': { max_retries: ..., seconds_delay: ... }, ... }
@error_handler = {}
yield(self) if block_given?
end
# The default Configuration object.
def self.default
@@default ||= Configuration.new
end
def configure
yield(self) if block_given?
end
def scheme=(scheme)
# remove :// from scheme
@scheme = scheme.sub(/:\/\//, '')
end
def host=(host)
# remove http(s):// and anything after a slash
@host = host.sub(/https?:\/\//, '').split('/').first
end
def base_path=(base_path)
# Add leading and trailing slashes to base_path
@base_path = "/#{base_path}".gsub(/\/+/, '/')
@base_path = '' if @base_path == '/'
end
# Returns base URL for specified operation based on server settings
def base_url(operation = nil)
index = server_operation_index.fetch(operation, server_index)
return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if index == nil
server_url(index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
end
# Gets API key (with prefix if set).
# @param [String] param_name the parameter name of API key auth
def api_key_with_prefix(param_name, param_alias = nil)
key = @api_key[param_name]
key = @api_key.fetch(param_alias, key) unless param_alias.nil?
if @api_key_prefix[param_name]
"#{@api_key_prefix[param_name]} #{key}"
else
key
end
end
# Gets Basic Auth token string
def basic_auth_token
'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
end
# Returns Auth Settings hash for api client.
def auth_settings
{
'oauth2' =>
{
type: 'oauth2',
in: 'header',
key: 'Authorization',
value: "Bearer #{access_token}"
},
}
end
# Returns an array of Server setting
def server_settings
[
{
url: "https://api.hubapi.com",
description: "No description provided",
}
]
end
def operation_server_settings
{
}
end
# Returns URL based on server settings
#
# @param index array index of the server settings
# @param variables hash of variable and the corresponding value
def server_url(index, variables = {}, servers = nil)
servers = server_settings if servers == nil
# check array index out of bound
if (index < 0 || index >= servers.size)
fail ArgumentError, "Invalid index #{index} when selecting the server. Must be less than #{servers.size}"
end
server = servers[index]
url = server[:url]
return url unless server.key? :variables
# go through variable and assign a value
server[:variables].each do |name, variable|
if variables.key?(name)
if (!server[:variables][name].key?(:enum_values) || server[:variables][name][:enum_values].include?(variables[name]))
url.gsub! "{" + name.to_s + "}", variables[name]
else
fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."
end
else
# use default value
url.gsub! "{" + name.to_s + "}", server[:variables][name][:default_value]
end
end
url
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/settings/business_units/api_client.rb | lib/hubspot/codegen/settings/business_units/api_client.rb | =begin
#Business Units
#Retrieve Business Unit information.
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'json'
require 'logger'
require 'tempfile'
require 'time'
require 'typhoeus'
module Hubspot
module Settings
module BusinessUnits
class ApiClient
# The Configuration object holding settings to be used in the API client.
attr_accessor :config
# Defines the headers to be used in HTTP requests of all API calls by default.
#
# @return [Hash]
attr_accessor :default_headers
# Initializes the ApiClient
# @option config [Configuration] Configuration for initializing the object, default to Configuration.default
def initialize(config = Configuration.default)
@config = config
@user_agent = "hubspot-api-client-ruby; #{VERSION}"
@default_headers = {
'Content-Type' => 'application/json',
'User-Agent' => @user_agent
}
end
def self.default
@@default ||= ApiClient.new
end
# Call an API with given options.
#
# @return [Array<(Object, Integer, Hash)>] an array of 3 elements:
# the data deserialized from response body (could be nil), response status code and response headers.
def call_api(http_method, path, opts = {})
request = build_request(http_method, path, opts)
response = request.run
if @config.debugging
@config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
end
if !response.success? && config.error_handler.any?
config.error_handler.each do |statuses, opts|
statuses = statuses.is_a?(Integer) ? [statuses] : statuses
retries = opts[:max_retries] || 5
while retries > 0 && statuses.include?(response.code)
sleep opts[:seconds_delay] if opts[:seconds_delay]
response = request.run
opts[:retry_block].call if opts[:retry_block]
retries -= 1
end
end
end
unless response.success?
if response.timed_out?
fail ApiError.new('Connection timed out')
elsif response.code == 0
# Errors from libcurl will be made visible here
fail ApiError.new(:code => 0,
:message => response.return_message)
else
fail ApiError.new(:code => response.code,
:response_headers => response.headers,
:response_body => response.body),
response.status_message
end
end
if opts[:return_type]
data = deserialize(response, opts[:return_type])
else
data = nil
end
return data, response.code, response.headers
end
# Builds the HTTP request
#
# @param [String] http_method HTTP method/verb (e.g. POST)
# @param [String] path URL path (e.g. /account/new)
# @option opts [Hash] :header_params Header parameters
# @option opts [Hash] :query_params Query parameters
# @option opts [Hash] :form_params Query parameters
# @option opts [Object] :body HTTP body (JSON/XML)
# @return [Typhoeus::Request] A Typhoeus Request
def build_request(http_method, path, opts = {})
url = build_request_url(path, opts)
http_method = http_method.to_sym.downcase
header_params = @default_headers.merge(opts[:header_params] || {})
query_params = opts[:query_params] || {}
form_params = opts[:form_params] || {}
follow_location = opts[:follow_location] || true
update_params_for_auth! header_params, query_params, opts[:auth_names]
# set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)
_verify_ssl_host = @config.verify_ssl_host ? 2 : 0
req_opts = {
:method => http_method,
:headers => header_params,
:params => query_params,
:params_encoding => @config.params_encoding,
:timeout => @config.timeout,
:ssl_verifypeer => @config.verify_ssl,
:ssl_verifyhost => _verify_ssl_host,
:sslcert => @config.cert_file,
:sslkey => @config.key_file,
:verbose => @config.debugging,
:followlocation => follow_location
}
# set custom cert, if provided
req_opts[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert
if [:post, :patch, :put, :delete].include?(http_method)
req_body = build_request_body(header_params, form_params, opts[:body])
req_opts.update :body => req_body
if @config.debugging
@config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n"
end
end
request = Typhoeus::Request.new(url, req_opts)
download_file(request) if opts[:return_type] == 'File'
request
end
# Builds the HTTP request body
#
# @param [Hash] header_params Header parameters
# @param [Hash] form_params Query parameters
# @param [Object] body HTTP body (JSON/XML)
# @return [String] HTTP body data in the form of string
def build_request_body(header_params, form_params, body)
# http form
if header_params['Content-Type'] == 'application/x-www-form-urlencoded' ||
header_params['Content-Type'] == 'multipart/form-data'
data = {}
form_params.each do |key, value|
case value
when ::File, ::Array, nil
# let typhoeus handle File, Array and nil parameters
data[key] = value
else
data[key] = value.to_s
end
end
elsif body
data = body.is_a?(String) ? body : body.to_json
else
data = nil
end
data
end
# Save response body into a file in (the defined) temporary folder, using the filename
# from the "Content-Disposition" header if provided, otherwise a random filename.
# The response body is written to the file in chunks in order to handle files which
# size is larger than maximum Ruby String or even larger than the maximum memory a Ruby
# process can use.
#
# @see Configuration#temp_folder_path
def download_file(request)
tempfile = nil
encoding = nil
request.on_headers do |response|
content_disposition = response.headers['Content-Disposition']
if content_disposition && content_disposition =~ /filename=/i
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
prefix = sanitize_filename(filename)
else
prefix = 'download-'
end
prefix = prefix + '-' unless prefix.end_with?('-')
encoding = response.body.encoding
tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
@tempfile = tempfile
end
request.on_body do |chunk|
chunk.force_encoding(encoding)
tempfile.write(chunk)
end
request.on_complete do |response|
if tempfile
tempfile.close
@config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
"will be deleted automatically with GC. It's also recommended to delete the temp file "\
"explicitly with `tempfile.delete`"
end
end
end
# Check if the given MIME is a JSON MIME.
# JSON MIME examples:
# application/json
# application/json; charset=UTF8
# APPLICATION/JSON
# */*
# @param [String] mime MIME
# @return [Boolean] True if the MIME is application/json
def json_mime?(mime)
(mime == '*/*') || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
end
# Deserialize the response to the given return type.
#
# @param [Response] response HTTP response
# @param [String] return_type some examples: "User", "Array<User>", "Hash<String, Integer>"
def deserialize(response, return_type)
body = response.body
# handle file downloading - return the File instance processed in request callbacks
# note that response body is empty when the file is written in chunks in request on_body callback
return @tempfile if return_type == 'File'
return nil if body.nil? || body.empty?
# return response body directly for String return type
return body if return_type == 'String'
# ensuring a default content type
content_type = response.headers['Content-Type'] || 'application/json'
fail "Content-Type is not supported: #{content_type}" unless json_mime?(content_type)
begin
data = JSON.parse("[#{body}]", :symbolize_names => true)[0]
rescue JSON::ParserError => e
if %w(String Date Time).include?(return_type)
data = body
else
raise e
end
end
convert_to_type data, return_type
end
# Convert data to the given return type.
# @param [Object] data Data to be converted
# @param [String] return_type Return type
# @return [Mixed] Data in a particular type
def convert_to_type(data, return_type)
return nil if data.nil?
case return_type
when 'String'
data.to_s
when 'Integer'
data.to_i
when 'Float'
data.to_f
when 'Boolean'
data == true
when 'Time'
# parse date time (expecting ISO 8601 format)
Time.parse data
when 'Date'
# parse date time (expecting ISO 8601 format)
Date.parse data
when 'Object'
# generic object (usually a Hash), return directly
data
when /\AArray<(.+)>\z/
# e.g. Array<Pet>
sub_type = $1
data.map { |item| convert_to_type(item, sub_type) }
when /\AHash\<String, (.+)\>\z/
# e.g. Hash<String, Integer>
sub_type = $1
{}.tap do |hash|
data.each { |k, v| hash[k] = convert_to_type(v, sub_type) }
end
else
# models (e.g. Pet) or oneOf
klass = Hubspot::Settings::BusinessUnits.const_get(return_type)
klass.respond_to?(:openapi_one_of) ? klass.build(data) : klass.build_from_hash(data)
end
end
# Sanitize filename by removing path.
# e.g. ../../sun.gif becomes sun.gif
#
# @param [String] filename the filename to be sanitized
# @return [String] the sanitized filename
def sanitize_filename(filename)
filename.gsub(/.*[\/\\]/, '')
end
def build_request_url(path, opts = {})
# Add leading and trailing slashes to path
path = "/#{path}".gsub(/\/+/, '/')
@config.base_url(opts[:operation]) + path
end
# Update header and query params based on authentication settings.
#
# @param [Hash] header_params Header parameters
# @param [Hash] query_params Query parameters
# @param [String] auth_names Authentication scheme name
def update_params_for_auth!(header_params, query_params, auth_names)
Array(auth_names).each do |auth_name|
auth_setting = @config.auth_settings[auth_name]
next unless auth_setting
case auth_setting[:in]
when 'header' then header_params[auth_setting[:key]] = auth_setting[:value]
when 'query' then query_params[auth_setting[:key]] = auth_setting[:value]
else fail ArgumentError, 'Authentication token must be in `query` or `header`'
end
end
end
# Sets user agent in HTTP header
#
# @param [String] user_agent User agent (e.g. openapi-generator/ruby/1.0.0)
def user_agent=(user_agent)
@user_agent = user_agent
@default_headers['User-Agent'] = @user_agent
end
# Return Accept header based on an array of accepts provided.
# @param [Array] accepts array for Accept
# @return [String] the Accept header (e.g. application/json)
def select_header_accept(accepts)
return nil if accepts.nil? || accepts.empty?
# use JSON when present, otherwise use all of the provided
json_accept = accepts.find { |s| json_mime?(s) }
json_accept || accepts.join(',')
end
# Return Content-Type header based on an array of content types provided.
# @param [Array] content_types array for Content-Type
# @return [String] the Content-Type header (e.g. application/json)
def select_header_content_type(content_types)
# return nil by default
return if content_types.nil? || content_types.empty?
# use JSON when present, otherwise use the first one
json_content_type = content_types.find { |s| json_mime?(s) }
json_content_type || content_types.first
end
# Convert object (array, hash, object, etc) to JSON string.
# @param [Object] model object to be converted into JSON string
# @return [String] JSON string representation of the object
def object_to_http_body(model)
return model if model.nil? || model.is_a?(String)
local_body = nil
if model.is_a?(Array)
local_body = model.map { |m| object_to_hash(m) }
else
local_body = object_to_hash(model)
end
local_body.to_json
end
# Convert object(non-array) to hash.
# @param [Object] obj object to be converted into JSON string
# @return [String] JSON string representation of the object
def object_to_hash(obj)
if obj.respond_to?(:to_hash)
obj.to_hash
else
obj
end
end
# Build parameter value according to the given collection format.
# @param [String] collection_format one of :csv, :ssv, :tsv, :pipes and :multi
def build_collection_param(param, collection_format)
case collection_format
when :csv
param.join(',')
when :ssv
param.join(' ')
when :tsv
param.join("\t")
when :pipes
param.join('|')
when :multi
# return the array directly as typhoeus will handle it as expected
param
else
fail "unknown collection format: #{collection_format.inspect}"
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/settings/business_units/models/collection_response_public_business_unit_no_paging.rb | lib/hubspot/codegen/settings/business_units/models/collection_response_public_business_unit_no_paging.rb | =begin
#Business Units
#Retrieve Business Unit information.
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Settings
module BusinessUnits
# A response object containing a collection of Business Units
class CollectionResponsePublicBusinessUnitNoPaging
# The collection of Business Units
attr_accessor :results
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'results' => :'results'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'results' => :'Array<PublicBusinessUnit>'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Settings::BusinessUnits::CollectionResponsePublicBusinessUnitNoPaging` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Settings::BusinessUnits::CollectionResponsePublicBusinessUnitNoPaging`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'results')
if (value = attributes[:'results']).is_a?(Array)
self.results = value
end
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @results.nil?
invalid_properties.push('invalid value for "results", results cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @results.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
results == o.results
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[results].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Settings::BusinessUnits.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/settings/business_units/models/public_business_unit.rb | lib/hubspot/codegen/settings/business_units/models/public_business_unit.rb | =begin
#Business Units
#Retrieve Business Unit information.
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Settings
module BusinessUnits
# A Business Unit
class PublicBusinessUnit
attr_accessor :logo_metadata
# The Business Unit's name
attr_accessor :name
# The Business Unit's unique ID
attr_accessor :id
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'logo_metadata' => :'logoMetadata',
:'name' => :'name',
:'id' => :'id'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'logo_metadata' => :'PublicBusinessUnitLogoMetadata',
:'name' => :'String',
:'id' => :'String'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Settings::BusinessUnits::PublicBusinessUnit` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Settings::BusinessUnits::PublicBusinessUnit`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'logo_metadata')
self.logo_metadata = attributes[:'logo_metadata']
end
if attributes.key?(:'name')
self.name = attributes[:'name']
end
if attributes.key?(:'id')
self.id = attributes[:'id']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @name.nil?
invalid_properties.push('invalid value for "name", name cannot be nil.')
end
if @id.nil?
invalid_properties.push('invalid value for "id", id cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @name.nil?
return false if @id.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
logo_metadata == o.logo_metadata &&
name == o.name &&
id == o.id
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[logo_metadata, name, id].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Settings::BusinessUnits.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/settings/business_units/models/error_detail.rb | lib/hubspot/codegen/settings/business_units/models/error_detail.rb | =begin
#Business Units
#Retrieve Business Unit information.
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Settings
module BusinessUnits
class ErrorDetail
# A specific category that contains more specific detail about the error
attr_accessor :sub_category
# The status code associated with the error detail
attr_accessor :code
# The name of the field or parameter in which the error was found.
attr_accessor :_in
# Context about the error condition
attr_accessor :context
# A human readable message describing the error along with remediation steps where appropriate
attr_accessor :message
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'sub_category' => :'subCategory',
:'code' => :'code',
:'_in' => :'in',
:'context' => :'context',
:'message' => :'message'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'sub_category' => :'String',
:'code' => :'String',
:'_in' => :'String',
:'context' => :'Hash<String, Array<String>>',
:'message' => :'String'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Settings::BusinessUnits::ErrorDetail` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Settings::BusinessUnits::ErrorDetail`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'sub_category')
self.sub_category = attributes[:'sub_category']
end
if attributes.key?(:'code')
self.code = attributes[:'code']
end
if attributes.key?(:'_in')
self._in = attributes[:'_in']
end
if attributes.key?(:'context')
if (value = attributes[:'context']).is_a?(Hash)
self.context = value
end
end
if attributes.key?(:'message')
self.message = attributes[:'message']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @message.nil?
invalid_properties.push('invalid value for "message", message cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @message.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
sub_category == o.sub_category &&
code == o.code &&
_in == o._in &&
context == o.context &&
message == o.message
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[sub_category, code, _in, context, message].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Settings::BusinessUnits.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/settings/business_units/models/public_business_unit_logo_metadata.rb | lib/hubspot/codegen/settings/business_units/models/public_business_unit_logo_metadata.rb | =begin
#Business Units
#Retrieve Business Unit information.
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Settings
module BusinessUnits
# A Business Unit's logo metadata
class PublicBusinessUnitLogoMetadata
# The logo's alt text
attr_accessor :logo_alt_text
# The logo's resized url
attr_accessor :resized_url
# The logo's url
attr_accessor :logo_url
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'logo_alt_text' => :'logoAltText',
:'resized_url' => :'resizedUrl',
:'logo_url' => :'logoUrl'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'logo_alt_text' => :'String',
:'resized_url' => :'String',
:'logo_url' => :'String'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Settings::BusinessUnits::PublicBusinessUnitLogoMetadata` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Settings::BusinessUnits::PublicBusinessUnitLogoMetadata`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'logo_alt_text')
self.logo_alt_text = attributes[:'logo_alt_text']
end
if attributes.key?(:'resized_url')
self.resized_url = attributes[:'resized_url']
end
if attributes.key?(:'logo_url')
self.logo_url = attributes[:'logo_url']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
logo_alt_text == o.logo_alt_text &&
resized_url == o.resized_url &&
logo_url == o.logo_url
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[logo_alt_text, resized_url, logo_url].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Settings::BusinessUnits.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/settings/business_units/models/error.rb | lib/hubspot/codegen/settings/business_units/models/error.rb | =begin
#Business Units
#Retrieve Business Unit information.
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Settings
module BusinessUnits
class Error
# A specific category that contains more specific detail about the error
attr_accessor :sub_category
# Context about the error condition
attr_accessor :context
# A unique identifier for the request. Include this value with any error reports or support tickets
attr_accessor :correlation_id
# A map of link names to associated URIs containing documentation about the error or recommended remediation steps
attr_accessor :links
# A human readable message describing the error along with remediation steps where appropriate
attr_accessor :message
# The error category
attr_accessor :category
# further information about the error
attr_accessor :errors
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'sub_category' => :'subCategory',
:'context' => :'context',
:'correlation_id' => :'correlationId',
:'links' => :'links',
:'message' => :'message',
:'category' => :'category',
:'errors' => :'errors'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'sub_category' => :'String',
:'context' => :'Hash<String, Array<String>>',
:'correlation_id' => :'String',
:'links' => :'Hash<String, String>',
:'message' => :'String',
:'category' => :'String',
:'errors' => :'Array<ErrorDetail>'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Settings::BusinessUnits::Error` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Settings::BusinessUnits::Error`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'sub_category')
self.sub_category = attributes[:'sub_category']
end
if attributes.key?(:'context')
if (value = attributes[:'context']).is_a?(Hash)
self.context = value
end
end
if attributes.key?(:'correlation_id')
self.correlation_id = attributes[:'correlation_id']
end
if attributes.key?(:'links')
if (value = attributes[:'links']).is_a?(Hash)
self.links = value
end
end
if attributes.key?(:'message')
self.message = attributes[:'message']
end
if attributes.key?(:'category')
self.category = attributes[:'category']
end
if attributes.key?(:'errors')
if (value = attributes[:'errors']).is_a?(Array)
self.errors = value
end
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @correlation_id.nil?
invalid_properties.push('invalid value for "correlation_id", correlation_id cannot be nil.')
end
if @message.nil?
invalid_properties.push('invalid value for "message", message cannot be nil.')
end
if @category.nil?
invalid_properties.push('invalid value for "category", category cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @correlation_id.nil?
return false if @message.nil?
return false if @category.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
sub_category == o.sub_category &&
context == o.context &&
correlation_id == o.correlation_id &&
links == o.links &&
message == o.message &&
category == o.category &&
errors == o.errors
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[sub_category, context, correlation_id, links, message, category, errors].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Settings::BusinessUnits.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/settings/business_units/api/business_unit_api.rb | lib/hubspot/codegen/settings/business_units/api/business_unit_api.rb | =begin
#Business Units
#Retrieve Business Unit information.
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'cgi'
module Hubspot
module Settings
module BusinessUnits
class BusinessUnitApi
attr_accessor :api_client
def initialize(api_client = ApiClient.default)
@api_client = api_client
end
# Get Business Units for a user
# Get Business Units identified by `userId`. The `userId` refers to the user’s ID.
# @param user_id [String] Identifier of user to retrieve.
# @param [Hash] opts the optional parameters
# @option opts [Array<String>] :properties The names of properties to optionally include in the response body. The only valid value is `logoMetadata`.
# @option opts [Array<String>] :name The names of Business Units to retrieve. If empty or not provided, then all associated Business Units will be returned.
# @return [CollectionResponsePublicBusinessUnitNoPaging]
def get_by_user_id(user_id, opts = {})
data, _status_code, _headers = get_by_user_id_with_http_info(user_id, opts)
data
end
# Get Business Units for a user
# Get Business Units identified by `userId`. The `userId` refers to the user’s ID.
# @param user_id [String] Identifier of user to retrieve.
# @param [Hash] opts the optional parameters
# @option opts [Array<String>] :properties The names of properties to optionally include in the response body. The only valid value is `logoMetadata`.
# @option opts [Array<String>] :name The names of Business Units to retrieve. If empty or not provided, then all associated Business Units will be returned.
# @return [Array<(CollectionResponsePublicBusinessUnitNoPaging, Integer, Hash)>] CollectionResponsePublicBusinessUnitNoPaging data, response status code and response headers
def get_by_user_id_with_http_info(user_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: BusinessUnitApi.get_by_user_id ...'
end
# verify the required parameter 'user_id' is set
if @api_client.config.client_side_validation && user_id.nil?
fail ArgumentError, "Missing the required parameter 'user_id' when calling BusinessUnitApi.get_by_user_id"
end
# resource path
local_var_path = '/business-units/v3/business-units/user/{userId}'.sub('{' + 'userId' + '}', CGI.escape(user_id.to_s))
# query parameters
query_params = opts[:query_params] || {}
query_params[:'properties'] = @api_client.build_collection_param(opts[:'properties'], :csv) if !opts[:'properties'].nil?
query_params[:'name'] = @api_client.build_collection_param(opts[:'name'], :multi) if !opts[:'name'].nil?
# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body]
# return_type
return_type = opts[:debug_return_type] || 'CollectionResponsePublicBusinessUnitNoPaging'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"BusinessUnitApi.get_by_user_id",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: BusinessUnitApi#get_by_user_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/files/api_error.rb | lib/hubspot/codegen/files/api_error.rb | =begin
#Files
#Upload and manage files.
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
module Hubspot
module Files
class ApiError < ::StandardError
attr_reader :code, :response_headers, :response_body
# Usage examples:
# ApiError.new
# ApiError.new("message")
# ApiError.new(:code => 500, :response_headers => {}, :response_body => "")
# ApiError.new(:code => 404, :message => "Not Found")
def initialize(arg = nil)
if arg.is_a? Hash
if arg.key?(:message) || arg.key?('message')
super(arg[:message] || arg['message'])
else
super arg
end
arg.each do |k, v|
instance_variable_set "@#{k}", v
end
else
super arg
end
end
# Override to_s to display a friendly error message
def to_s
message
end
def message
if @message.nil?
msg = "Error message: the server returns an error"
else
msg = @message
end
msg += "\nHTTP status code: #{code}" if code
msg += "\nResponse headers: #{response_headers}" if response_headers
msg += "\nResponse body: #{response_body}" if response_body
msg
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/files/configuration.rb | lib/hubspot/codegen/files/configuration.rb | =begin
#Files
#Upload and manage files.
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
module Hubspot
module Files
class Configuration
# Defines url scheme
attr_accessor :scheme
# Defines url host
attr_accessor :host
# Defines url base path
attr_accessor :base_path
# Define server configuration index
attr_accessor :server_index
# Define server operation configuration index
attr_accessor :server_operation_index
# Default server variables
attr_accessor :server_variables
# Default server operation variables
attr_accessor :server_operation_variables
# Defines API keys used with API Key authentications.
#
# @return [Hash] key: parameter name, value: parameter value (API key)
#
# @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
# config.api_key['api_key'] = 'xxx'
attr_accessor :api_key
# Defines API key prefixes used with API Key authentications.
#
# @return [Hash] key: parameter name, value: API key prefix
#
# @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
# config.api_key_prefix['api_key'] = 'Token'
attr_accessor :api_key_prefix
# Defines the username used with HTTP basic authentication.
#
# @return [String]
attr_accessor :username
# Defines the password used with HTTP basic authentication.
#
# @return [String]
attr_accessor :password
# Defines the access token (Bearer) used with OAuth2.
attr_accessor :access_token
# Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
# details will be logged with `logger.debug` (see the `logger` attribute).
# Default to false.
#
# @return [true, false]
attr_accessor :debugging
# Defines the logger used for debugging.
# Default to `Rails.logger` (when in Rails) or logging to STDOUT.
#
# @return [#debug]
attr_accessor :logger
# Defines the temporary folder to store downloaded files
# (for API endpoints that have file response).
# Default to use `Tempfile`.
#
# @return [String]
attr_accessor :temp_folder_path
# The time limit for HTTP request in seconds.
# Default to 0 (never times out).
attr_accessor :timeout
# Set this to false to skip client side validation in the operation.
# Default to true.
# @return [true, false]
attr_accessor :client_side_validation
### TLS/SSL setting
# Set this to false to skip verifying SSL certificate when calling API from https server.
# Default to true.
#
# @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
#
# @return [true, false]
attr_accessor :verify_ssl
### TLS/SSL setting
# Set this to false to skip verifying SSL host name
# Default to true.
#
# @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
#
# @return [true, false]
attr_accessor :verify_ssl_host
### TLS/SSL setting
# Set this to customize the certificate file to verify the peer.
#
# @return [String] the path to the certificate file
#
# @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code:
# https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
attr_accessor :ssl_ca_cert
### TLS/SSL setting
# Client certificate file (for client certificate)
attr_accessor :cert_file
### TLS/SSL setting
# Client private key file (for client certificate)
attr_accessor :key_file
# Set this to customize parameters encoding of array parameter with multi collectionFormat.
# Default to nil.
#
# @see The params_encoding option of Ethon. Related source code:
# https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
attr_accessor :params_encoding
attr_accessor :inject_format
attr_accessor :force_ending_format
attr_accessor :error_handler
def initialize
@scheme = 'https'
@host = 'api.hubapi.com'
@base_path = ''
@server_index = 0
@server_operation_index = {}
@server_variables = {}
@server_operation_variables = {}
@api_key = {}
@api_key_prefix = {}
@client_side_validation = true
@verify_ssl = true
@verify_ssl_host = true
@cert_file = nil
@key_file = nil
@timeout = 0
@params_encoding = nil
@debugging = false
@inject_format = false
@force_ending_format = false
@logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
# error_handler params: { 'status_code': { max_retries: ..., seconds_delay: ... }, ... }
@error_handler = {}
yield(self) if block_given?
end
# The default Configuration object.
def self.default
@@default ||= Configuration.new
end
def configure
yield(self) if block_given?
end
def scheme=(scheme)
# remove :// from scheme
@scheme = scheme.sub(/:\/\//, '')
end
def host=(host)
# remove http(s):// and anything after a slash
@host = host.sub(/https?:\/\//, '').split('/').first
end
def base_path=(base_path)
# Add leading and trailing slashes to base_path
@base_path = "/#{base_path}".gsub(/\/+/, '/')
@base_path = '' if @base_path == '/'
end
# Returns base URL for specified operation based on server settings
def base_url(operation = nil)
index = server_operation_index.fetch(operation, server_index)
return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if index == nil
server_url(index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
end
# Gets API key (with prefix if set).
# @param [String] param_name the parameter name of API key auth
def api_key_with_prefix(param_name, param_alias = nil)
key = @api_key[param_name]
key = @api_key.fetch(param_alias, key) unless param_alias.nil?
if @api_key_prefix[param_name]
"#{@api_key_prefix[param_name]} #{key}"
else
key
end
end
# Gets Basic Auth token string
def basic_auth_token
'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
end
# Returns Auth Settings hash for api client.
def auth_settings
{
'oauth2' =>
{
type: 'oauth2',
in: 'header',
key: 'Authorization',
value: "Bearer #{access_token}"
},
}
end
# Returns an array of Server setting
def server_settings
[
{
url: "https://api.hubapi.com",
description: "No description provided",
}
]
end
def operation_server_settings
{
}
end
# Returns URL based on server settings
#
# @param index array index of the server settings
# @param variables hash of variable and the corresponding value
def server_url(index, variables = {}, servers = nil)
servers = server_settings if servers == nil
# check array index out of bound
if (index < 0 || index >= servers.size)
fail ArgumentError, "Invalid index #{index} when selecting the server. Must be less than #{servers.size}"
end
server = servers[index]
url = server[:url]
return url unless server.key? :variables
# go through variable and assign a value
server[:variables].each do |name, variable|
if variables.key?(name)
if (!server[:variables][name].key?(:enum_values) || server[:variables][name][:enum_values].include?(variables[name]))
url.gsub! "{" + name.to_s + "}", variables[name]
else
fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."
end
else
# use default value
url.gsub! "{" + name.to_s + "}", server[:variables][name][:default_value]
end
end
url
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/files/api_client.rb | lib/hubspot/codegen/files/api_client.rb | =begin
#Files
#Upload and manage files.
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'json'
require 'logger'
require 'tempfile'
require 'time'
require 'typhoeus'
module Hubspot
module Files
class ApiClient
# The Configuration object holding settings to be used in the API client.
attr_accessor :config
# Defines the headers to be used in HTTP requests of all API calls by default.
#
# @return [Hash]
attr_accessor :default_headers
# Initializes the ApiClient
# @option config [Configuration] Configuration for initializing the object, default to Configuration.default
def initialize(config = Configuration.default)
@config = config
@user_agent = "hubspot-api-client-ruby; #{VERSION}"
@default_headers = {
'Content-Type' => 'application/json',
'User-Agent' => @user_agent
}
end
def self.default
@@default ||= ApiClient.new
end
# Call an API with given options.
#
# @return [Array<(Object, Integer, Hash)>] an array of 3 elements:
# the data deserialized from response body (could be nil), response status code and response headers.
def call_api(http_method, path, opts = {})
request = build_request(http_method, path, opts)
response = request.run
if @config.debugging
@config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
end
if !response.success? && config.error_handler.any?
config.error_handler.each do |statuses, opts|
statuses = statuses.is_a?(Integer) ? [statuses] : statuses
retries = opts[:max_retries] || 5
while retries > 0 && statuses.include?(response.code)
sleep opts[:seconds_delay] if opts[:seconds_delay]
response = request.run
opts[:retry_block].call if opts[:retry_block]
retries -= 1
end
end
end
unless response.success?
if response.timed_out?
fail ApiError.new('Connection timed out')
elsif response.code == 0
# Errors from libcurl will be made visible here
fail ApiError.new(:code => 0,
:message => response.return_message)
else
fail ApiError.new(:code => response.code,
:response_headers => response.headers,
:response_body => response.body),
response.status_message
end
end
if opts[:return_type]
data = deserialize(response, opts[:return_type])
else
data = nil
end
return data, response.code, response.headers
end
# Builds the HTTP request
#
# @param [String] http_method HTTP method/verb (e.g. POST)
# @param [String] path URL path (e.g. /account/new)
# @option opts [Hash] :header_params Header parameters
# @option opts [Hash] :query_params Query parameters
# @option opts [Hash] :form_params Query parameters
# @option opts [Object] :body HTTP body (JSON/XML)
# @return [Typhoeus::Request] A Typhoeus Request
def build_request(http_method, path, opts = {})
url = build_request_url(path, opts)
http_method = http_method.to_sym.downcase
header_params = @default_headers.merge(opts[:header_params] || {})
query_params = opts[:query_params] || {}
form_params = opts[:form_params] || {}
follow_location = opts[:follow_location] || true
update_params_for_auth! header_params, query_params, opts[:auth_names]
# set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)
_verify_ssl_host = @config.verify_ssl_host ? 2 : 0
req_opts = {
:method => http_method,
:headers => header_params,
:params => query_params,
:params_encoding => @config.params_encoding,
:timeout => @config.timeout,
:ssl_verifypeer => @config.verify_ssl,
:ssl_verifyhost => _verify_ssl_host,
:sslcert => @config.cert_file,
:sslkey => @config.key_file,
:verbose => @config.debugging,
:followlocation => follow_location
}
# set custom cert, if provided
req_opts[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert
if [:post, :patch, :put, :delete].include?(http_method)
req_body = build_request_body(header_params, form_params, opts[:body])
req_opts.update :body => req_body
if @config.debugging
@config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n"
end
end
request = Typhoeus::Request.new(url, req_opts)
download_file(request) if opts[:return_type] == 'File'
request
end
# Builds the HTTP request body
#
# @param [Hash] header_params Header parameters
# @param [Hash] form_params Query parameters
# @param [Object] body HTTP body (JSON/XML)
# @return [String] HTTP body data in the form of string
def build_request_body(header_params, form_params, body)
# http form
if header_params['Content-Type'] == 'application/x-www-form-urlencoded' ||
header_params['Content-Type'] == 'multipart/form-data'
data = {}
form_params.each do |key, value|
case value
when ::File, ::Array, nil
# let typhoeus handle File, Array and nil parameters
data[key] = value
else
data[key] = value.to_s
end
end
elsif body
data = body.is_a?(String) ? body : body.to_json
else
data = nil
end
data
end
# Save response body into a file in (the defined) temporary folder, using the filename
# from the "Content-Disposition" header if provided, otherwise a random filename.
# The response body is written to the file in chunks in order to handle files which
# size is larger than maximum Ruby String or even larger than the maximum memory a Ruby
# process can use.
#
# @see Configuration#temp_folder_path
def download_file(request)
tempfile = nil
encoding = nil
request.on_headers do |response|
content_disposition = response.headers['Content-Disposition']
if content_disposition && content_disposition =~ /filename=/i
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
prefix = sanitize_filename(filename)
else
prefix = 'download-'
end
prefix = prefix + '-' unless prefix.end_with?('-')
encoding = response.body.encoding
tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
@tempfile = tempfile
end
request.on_body do |chunk|
chunk.force_encoding(encoding)
tempfile.write(chunk)
end
request.on_complete do |response|
if tempfile
tempfile.close
@config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
"will be deleted automatically with GC. It's also recommended to delete the temp file "\
"explicitly with `tempfile.delete`"
end
end
end
# Check if the given MIME is a JSON MIME.
# JSON MIME examples:
# application/json
# application/json; charset=UTF8
# APPLICATION/JSON
# */*
# @param [String] mime MIME
# @return [Boolean] True if the MIME is application/json
def json_mime?(mime)
(mime == '*/*') || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
end
# Deserialize the response to the given return type.
#
# @param [Response] response HTTP response
# @param [String] return_type some examples: "User", "Array<User>", "Hash<String, Integer>"
def deserialize(response, return_type)
body = response.body
# handle file downloading - return the File instance processed in request callbacks
# note that response body is empty when the file is written in chunks in request on_body callback
return @tempfile if return_type == 'File'
return nil if body.nil? || body.empty?
# return response body directly for String return type
return body if return_type == 'String'
# ensuring a default content type
content_type = response.headers['Content-Type'] || 'application/json'
fail "Content-Type is not supported: #{content_type}" unless json_mime?(content_type)
begin
data = JSON.parse("[#{body}]", :symbolize_names => true)[0]
rescue JSON::ParserError => e
if %w(String Date Time).include?(return_type)
data = body
else
raise e
end
end
convert_to_type data, return_type
end
# Convert data to the given return type.
# @param [Object] data Data to be converted
# @param [String] return_type Return type
# @return [Mixed] Data in a particular type
def convert_to_type(data, return_type)
return nil if data.nil?
case return_type
when 'String'
data.to_s
when 'Integer'
data.to_i
when 'Float'
data.to_f
when 'Boolean'
data == true
when 'Time'
# parse date time (expecting ISO 8601 format)
Time.parse data
when 'Date'
# parse date time (expecting ISO 8601 format)
Date.parse data
when 'Object'
# generic object (usually a Hash), return directly
data
when /\AArray<(.+)>\z/
# e.g. Array<Pet>
sub_type = $1
data.map { |item| convert_to_type(item, sub_type) }
when /\AHash\<String, (.+)\>\z/
# e.g. Hash<String, Integer>
sub_type = $1
{}.tap do |hash|
data.each { |k, v| hash[k] = convert_to_type(v, sub_type) }
end
else
# models (e.g. Pet) or oneOf
klass = Hubspot::Files.const_get(return_type)
klass.respond_to?(:openapi_one_of) ? klass.build(data) : klass.build_from_hash(data)
end
end
# Sanitize filename by removing path.
# e.g. ../../sun.gif becomes sun.gif
#
# @param [String] filename the filename to be sanitized
# @return [String] the sanitized filename
def sanitize_filename(filename)
filename.gsub(/.*[\/\\]/, '')
end
def build_request_url(path, opts = {})
# Add leading and trailing slashes to path
path = "/#{path}".gsub(/\/+/, '/')
@config.base_url(opts[:operation]) + path
end
# Update header and query params based on authentication settings.
#
# @param [Hash] header_params Header parameters
# @param [Hash] query_params Query parameters
# @param [String] auth_names Authentication scheme name
def update_params_for_auth!(header_params, query_params, auth_names)
Array(auth_names).each do |auth_name|
auth_setting = @config.auth_settings[auth_name]
next unless auth_setting
case auth_setting[:in]
when 'header' then header_params[auth_setting[:key]] = auth_setting[:value]
when 'query' then query_params[auth_setting[:key]] = auth_setting[:value]
else fail ArgumentError, 'Authentication token must be in `query` or `header`'
end
end
end
# Sets user agent in HTTP header
#
# @param [String] user_agent User agent (e.g. openapi-generator/ruby/1.0.0)
def user_agent=(user_agent)
@user_agent = user_agent
@default_headers['User-Agent'] = @user_agent
end
# Return Accept header based on an array of accepts provided.
# @param [Array] accepts array for Accept
# @return [String] the Accept header (e.g. application/json)
def select_header_accept(accepts)
return nil if accepts.nil? || accepts.empty?
# use JSON when present, otherwise use all of the provided
json_accept = accepts.find { |s| json_mime?(s) }
json_accept || accepts.join(',')
end
# Return Content-Type header based on an array of content types provided.
# @param [Array] content_types array for Content-Type
# @return [String] the Content-Type header (e.g. application/json)
def select_header_content_type(content_types)
# return nil by default
return if content_types.nil? || content_types.empty?
# use JSON when present, otherwise use the first one
json_content_type = content_types.find { |s| json_mime?(s) }
json_content_type || content_types.first
end
# Convert object (array, hash, object, etc) to JSON string.
# @param [Object] model object to be converted into JSON string
# @return [String] JSON string representation of the object
def object_to_http_body(model)
return model if model.nil? || model.is_a?(String)
local_body = nil
if model.is_a?(Array)
local_body = model.map { |m| object_to_hash(m) }
else
local_body = object_to_hash(model)
end
local_body.to_json
end
# Convert object(non-array) to hash.
# @param [Object] obj object to be converted into JSON string
# @return [String] JSON string representation of the object
def object_to_hash(obj)
if obj.respond_to?(:to_hash)
obj.to_hash
else
obj
end
end
# Build parameter value according to the given collection format.
# @param [String] collection_format one of :csv, :ssv, :tsv, :pipes and :multi
def build_collection_param(param, collection_format)
case collection_format
when :csv
param.join(',')
when :ssv
param.join(' ')
when :tsv
param.join("\t")
when :pipes
param.join('|')
when :multi
# return the array directly as typhoeus will handle it as expected
param
else
fail "unknown collection format: #{collection_format.inspect}"
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/files/models/folder_action_response.rb | lib/hubspot/codegen/files/models/folder_action_response.rb | =begin
#Files
#Upload and manage files.
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Files
class FolderActionResponse
attr_accessor :result
# When the requested changes have been completed.
attr_accessor :completed_at
# Number of errors resulting from the requested changes.
attr_accessor :num_errors
# Timestamp representing when the task was requested.
attr_accessor :requested_at
# Timestamp representing when the task was started at.
attr_accessor :started_at
# Link to check the status of the task.
attr_accessor :links
# Detailed errors resulting from the task.
attr_accessor :errors
# ID of the task.
attr_accessor :task_id
# Current status of the task.
attr_accessor :status
class EnumAttributeValidator
attr_reader :datatype
attr_reader :allowable_values
def initialize(datatype, allowable_values)
@allowable_values = allowable_values.map do |value|
case datatype.to_s
when /Integer/i
value.to_i
when /Float/i
value.to_f
else
value
end
end
end
def valid?(value)
!value || allowable_values.include?(value)
end
end
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'result' => :'result',
:'completed_at' => :'completedAt',
:'num_errors' => :'numErrors',
:'requested_at' => :'requestedAt',
:'started_at' => :'startedAt',
:'links' => :'links',
:'errors' => :'errors',
:'task_id' => :'taskId',
:'status' => :'status'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'result' => :'Folder',
:'completed_at' => :'Time',
:'num_errors' => :'Integer',
:'requested_at' => :'Time',
:'started_at' => :'Time',
:'links' => :'Hash<String, String>',
:'errors' => :'Array<StandardError>',
:'task_id' => :'String',
:'status' => :'String'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Files::FolderActionResponse` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Files::FolderActionResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'result')
self.result = attributes[:'result']
end
if attributes.key?(:'completed_at')
self.completed_at = attributes[:'completed_at']
end
if attributes.key?(:'num_errors')
self.num_errors = attributes[:'num_errors']
end
if attributes.key?(:'requested_at')
self.requested_at = attributes[:'requested_at']
end
if attributes.key?(:'started_at')
self.started_at = attributes[:'started_at']
end
if attributes.key?(:'links')
if (value = attributes[:'links']).is_a?(Hash)
self.links = value
end
end
if attributes.key?(:'errors')
if (value = attributes[:'errors']).is_a?(Array)
self.errors = value
end
end
if attributes.key?(:'task_id')
self.task_id = attributes[:'task_id']
end
if attributes.key?(:'status')
self.status = attributes[:'status']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @completed_at.nil?
invalid_properties.push('invalid value for "completed_at", completed_at cannot be nil.')
end
if @started_at.nil?
invalid_properties.push('invalid value for "started_at", started_at cannot be nil.')
end
if @task_id.nil?
invalid_properties.push('invalid value for "task_id", task_id cannot be nil.')
end
if @status.nil?
invalid_properties.push('invalid value for "status", status cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @completed_at.nil?
return false if @started_at.nil?
return false if @task_id.nil?
return false if @status.nil?
status_validator = EnumAttributeValidator.new('String', ["PENDING", "PROCESSING", "CANCELED", "COMPLETE"])
return false unless status_validator.valid?(@status)
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] status Object to be assigned
def status=(status)
validator = EnumAttributeValidator.new('String', ["PENDING", "PROCESSING", "CANCELED", "COMPLETE"])
unless validator.valid?(status)
fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
end
@status = status
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
result == o.result &&
completed_at == o.completed_at &&
num_errors == o.num_errors &&
requested_at == o.requested_at &&
started_at == o.started_at &&
links == o.links &&
errors == o.errors &&
task_id == o.task_id &&
status == o.status
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[result, completed_at, num_errors, requested_at, started_at, links, errors, task_id, status].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Files.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/files/models/standard_error.rb | lib/hubspot/codegen/files/models/standard_error.rb | =begin
#Files
#Upload and manage files.
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Files
class StandardError
attr_accessor :sub_category
attr_accessor :context
attr_accessor :links
attr_accessor :id
attr_accessor :category
attr_accessor :message
attr_accessor :errors
attr_accessor :status
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'sub_category' => :'subCategory',
:'context' => :'context',
:'links' => :'links',
:'id' => :'id',
:'category' => :'category',
:'message' => :'message',
:'errors' => :'errors',
:'status' => :'status'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'sub_category' => :'Object',
:'context' => :'Hash<String, Array<String>>',
:'links' => :'Hash<String, String>',
:'id' => :'String',
:'category' => :'String',
:'message' => :'String',
:'errors' => :'Array<ErrorDetail>',
:'status' => :'String'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Files::StandardError` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Files::StandardError`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'sub_category')
self.sub_category = attributes[:'sub_category']
end
if attributes.key?(:'context')
if (value = attributes[:'context']).is_a?(Hash)
self.context = value
end
end
if attributes.key?(:'links')
if (value = attributes[:'links']).is_a?(Hash)
self.links = value
end
end
if attributes.key?(:'id')
self.id = attributes[:'id']
end
if attributes.key?(:'category')
self.category = attributes[:'category']
end
if attributes.key?(:'message')
self.message = attributes[:'message']
end
if attributes.key?(:'errors')
if (value = attributes[:'errors']).is_a?(Array)
self.errors = value
end
end
if attributes.key?(:'status')
self.status = attributes[:'status']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @context.nil?
invalid_properties.push('invalid value for "context", context cannot be nil.')
end
if @links.nil?
invalid_properties.push('invalid value for "links", links cannot be nil.')
end
if @category.nil?
invalid_properties.push('invalid value for "category", category cannot be nil.')
end
if @message.nil?
invalid_properties.push('invalid value for "message", message cannot be nil.')
end
if @errors.nil?
invalid_properties.push('invalid value for "errors", errors cannot be nil.')
end
if @status.nil?
invalid_properties.push('invalid value for "status", status cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @context.nil?
return false if @links.nil?
return false if @category.nil?
return false if @message.nil?
return false if @errors.nil?
return false if @status.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
sub_category == o.sub_category &&
context == o.context &&
links == o.links &&
id == o.id &&
category == o.category &&
message == o.message &&
errors == o.errors &&
status == o.status
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[sub_category, context, links, id, category, message, errors, status].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Files.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/files/models/signed_url.rb | lib/hubspot/codegen/files/models/signed_url.rb | =begin
#Files
#Upload and manage files.
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Files
# Signed Url object with optional ancillary metadata of requested file
class SignedUrl
# Extension of the requested file.
attr_accessor :extension
# Size in bytes of the requested file.
attr_accessor :size
# Name of the requested file.
attr_accessor :name
# For image and video files. The width of the file.
attr_accessor :width
# Type of the file. Can be IMG, DOCUMENT, AUDIO, MOVIE, or OTHER.
attr_accessor :type
# Signed URL with access to the specified file. Anyone with this URL will be able to access the file until it expires.
attr_accessor :url
# Timestamp of when the URL will no longer grant access to the file.
attr_accessor :expires_at
# For image and video files. The height of the file.
attr_accessor :height
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'extension' => :'extension',
:'size' => :'size',
:'name' => :'name',
:'width' => :'width',
:'type' => :'type',
:'url' => :'url',
:'expires_at' => :'expiresAt',
:'height' => :'height'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'extension' => :'String',
:'size' => :'Integer',
:'name' => :'String',
:'width' => :'Integer',
:'type' => :'String',
:'url' => :'String',
:'expires_at' => :'Time',
:'height' => :'Integer'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Files::SignedUrl` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Files::SignedUrl`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'extension')
self.extension = attributes[:'extension']
end
if attributes.key?(:'size')
self.size = attributes[:'size']
end
if attributes.key?(:'name')
self.name = attributes[:'name']
end
if attributes.key?(:'width')
self.width = attributes[:'width']
end
if attributes.key?(:'type')
self.type = attributes[:'type']
end
if attributes.key?(:'url')
self.url = attributes[:'url']
end
if attributes.key?(:'expires_at')
self.expires_at = attributes[:'expires_at']
end
if attributes.key?(:'height')
self.height = attributes[:'height']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @extension.nil?
invalid_properties.push('invalid value for "extension", extension cannot be nil.')
end
if @size.nil?
invalid_properties.push('invalid value for "size", size cannot be nil.')
end
if @name.nil?
invalid_properties.push('invalid value for "name", name cannot be nil.')
end
if @type.nil?
invalid_properties.push('invalid value for "type", type cannot be nil.')
end
if @url.nil?
invalid_properties.push('invalid value for "url", url cannot be nil.')
end
if @expires_at.nil?
invalid_properties.push('invalid value for "expires_at", expires_at cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @extension.nil?
return false if @size.nil?
return false if @name.nil?
return false if @type.nil?
return false if @url.nil?
return false if @expires_at.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
extension == o.extension &&
size == o.size &&
name == o.name &&
width == o.width &&
type == o.type &&
url == o.url &&
expires_at == o.expires_at &&
height == o.height
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[extension, size, name, width, type, url, expires_at, height].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Files.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/files/models/previous_page.rb | lib/hubspot/codegen/files/models/previous_page.rb | =begin
#Files
#Upload and manage files.
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Files
class PreviousPage
attr_accessor :before
attr_accessor :link
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'before' => :'before',
:'link' => :'link'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'before' => :'String',
:'link' => :'String'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Files::PreviousPage` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Files::PreviousPage`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'before')
self.before = attributes[:'before']
end
if attributes.key?(:'link')
self.link = attributes[:'link']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @before.nil?
invalid_properties.push('invalid value for "before", before cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @before.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
before == o.before &&
link == o.link
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[before, link].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Files.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/files/models/next_page.rb | lib/hubspot/codegen/files/models/next_page.rb | =begin
#Files
#Upload and manage files.
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Files
class NextPage
attr_accessor :link
attr_accessor :after
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'link' => :'link',
:'after' => :'after'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'link' => :'String',
:'after' => :'String'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Files::NextPage` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Files::NextPage`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'link')
self.link = attributes[:'link']
end
if attributes.key?(:'after')
self.after = attributes[:'after']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @after.nil?
invalid_properties.push('invalid value for "after", after cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @after.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
link == o.link &&
after == o.after
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[link, after].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Files.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/files/models/folder_input.rb | lib/hubspot/codegen/files/models/folder_input.rb | =begin
#Files
#Upload and manage files.
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Files
# Object for creating a folder.
class FolderInput
# FolderId of the parent of the created folder. If not specified, the folder will be created at the root level. parentFolderId and parentFolderPath cannot be set at the same time.
attr_accessor :parent_folder_id
# Path of the parent of the created folder. If not specified the folder will be created at the root level. parentFolderPath and parentFolderId cannot be set at the same time.
attr_accessor :parent_path
# Desired name for the folder.
attr_accessor :name
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'parent_folder_id' => :'parentFolderId',
:'parent_path' => :'parentPath',
:'name' => :'name'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'parent_folder_id' => :'String',
:'parent_path' => :'String',
:'name' => :'String'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Files::FolderInput` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Files::FolderInput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'parent_folder_id')
self.parent_folder_id = attributes[:'parent_folder_id']
end
if attributes.key?(:'parent_path')
self.parent_path = attributes[:'parent_path']
end
if attributes.key?(:'name')
self.name = attributes[:'name']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @name.nil?
invalid_properties.push('invalid value for "name", name cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @name.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
parent_folder_id == o.parent_folder_id &&
parent_path == o.parent_path &&
name == o.name
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[parent_folder_id, parent_path, name].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Files.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/files/models/folder_update_input_with_id.rb | lib/hubspot/codegen/files/models/folder_update_input_with_id.rb | =begin
#Files
#Upload and manage files.
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Files
class FolderUpdateInputWithId
attr_accessor :parent_folder_id
attr_accessor :name
attr_accessor :id
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'parent_folder_id' => :'parentFolderId',
:'name' => :'name',
:'id' => :'id'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'parent_folder_id' => :'Integer',
:'name' => :'String',
:'id' => :'String'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Files::FolderUpdateInputWithId` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Files::FolderUpdateInputWithId`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'parent_folder_id')
self.parent_folder_id = attributes[:'parent_folder_id']
end
if attributes.key?(:'name')
self.name = attributes[:'name']
end
if attributes.key?(:'id')
self.id = attributes[:'id']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @id.nil?
invalid_properties.push('invalid value for "id", id cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @id.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
parent_folder_id == o.parent_folder_id &&
name == o.name &&
id == o.id
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[parent_folder_id, name, id].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Files.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/files/models/file.rb | lib/hubspot/codegen/files/models/file.rb | =begin
#Files
#Upload and manage files.
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Files
# File
class File
# Extension of the file. ex: .jpg, .png, .gif, .pdf, etc.
attr_accessor :extension
# File access. Can be PUBLIC_INDEXABLE, PUBLIC_NOT_INDEXABLE, PRIVATE.
attr_accessor :access
# ID of the folder the file is in.
attr_accessor :parent_folder_id
attr_accessor :source_group
attr_accessor :file_md5
# Encoding of the file.
attr_accessor :encoding
# Type of the file. Can be IMG, DOCUMENT, AUDIO, MOVIE, or OTHER.
attr_accessor :type
# Previously \"archied\". Indicates if the file should be used when creating new content like web pages.
attr_accessor :is_usable_in_content
# URL of the given file. This URL can change depending on the domain settings of the account. Will use the select file hosting domain.
attr_accessor :url
attr_accessor :expires_at
# Creation time of the file object.
attr_accessor :created_at
# Deletion time of the file object.
attr_accessor :archived_at
# Path of the file in the file manager.
attr_accessor :path
# If the file is deleted.
attr_accessor :archived
# Size of the file in bytes.
attr_accessor :size
# Name of the file.
attr_accessor :name
# For image and video files, the width of the content.
attr_accessor :width
# File ID.
attr_accessor :id
# Default hosting URL of the file. This will use one of HubSpot's provided URLs to serve the file.
attr_accessor :default_hosting_url
# Timestamp of the latest update to the file.
attr_accessor :updated_at
# For image and video files, the height of the content.
attr_accessor :height
class EnumAttributeValidator
attr_reader :datatype
attr_reader :allowable_values
def initialize(datatype, allowable_values)
@allowable_values = allowable_values.map do |value|
case datatype.to_s
when /Integer/i
value.to_i
when /Float/i
value.to_f
else
value
end
end
end
def valid?(value)
!value || allowable_values.include?(value)
end
end
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'extension' => :'extension',
:'access' => :'access',
:'parent_folder_id' => :'parentFolderId',
:'source_group' => :'sourceGroup',
:'file_md5' => :'fileMd5',
:'encoding' => :'encoding',
:'type' => :'type',
:'is_usable_in_content' => :'isUsableInContent',
:'url' => :'url',
:'expires_at' => :'expiresAt',
:'created_at' => :'createdAt',
:'archived_at' => :'archivedAt',
:'path' => :'path',
:'archived' => :'archived',
:'size' => :'size',
:'name' => :'name',
:'width' => :'width',
:'id' => :'id',
:'default_hosting_url' => :'defaultHostingUrl',
:'updated_at' => :'updatedAt',
:'height' => :'height'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'extension' => :'String',
:'access' => :'String',
:'parent_folder_id' => :'String',
:'source_group' => :'String',
:'file_md5' => :'String',
:'encoding' => :'String',
:'type' => :'String',
:'is_usable_in_content' => :'Boolean',
:'url' => :'String',
:'expires_at' => :'Integer',
:'created_at' => :'Time',
:'archived_at' => :'Time',
:'path' => :'String',
:'archived' => :'Boolean',
:'size' => :'Integer',
:'name' => :'String',
:'width' => :'Integer',
:'id' => :'String',
:'default_hosting_url' => :'String',
:'updated_at' => :'Time',
:'height' => :'Integer'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Files::File` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Files::File`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'extension')
self.extension = attributes[:'extension']
end
if attributes.key?(:'access')
self.access = attributes[:'access']
end
if attributes.key?(:'parent_folder_id')
self.parent_folder_id = attributes[:'parent_folder_id']
end
if attributes.key?(:'source_group')
self.source_group = attributes[:'source_group']
end
if attributes.key?(:'file_md5')
self.file_md5 = attributes[:'file_md5']
end
if attributes.key?(:'encoding')
self.encoding = attributes[:'encoding']
end
if attributes.key?(:'type')
self.type = attributes[:'type']
end
if attributes.key?(:'is_usable_in_content')
self.is_usable_in_content = attributes[:'is_usable_in_content']
end
if attributes.key?(:'url')
self.url = attributes[:'url']
end
if attributes.key?(:'expires_at')
self.expires_at = attributes[:'expires_at']
end
if attributes.key?(:'created_at')
self.created_at = attributes[:'created_at']
end
if attributes.key?(:'archived_at')
self.archived_at = attributes[:'archived_at']
end
if attributes.key?(:'path')
self.path = attributes[:'path']
end
if attributes.key?(:'archived')
self.archived = attributes[:'archived']
end
if attributes.key?(:'size')
self.size = attributes[:'size']
end
if attributes.key?(:'name')
self.name = attributes[:'name']
end
if attributes.key?(:'width')
self.width = attributes[:'width']
end
if attributes.key?(:'id')
self.id = attributes[:'id']
end
if attributes.key?(:'default_hosting_url')
self.default_hosting_url = attributes[:'default_hosting_url']
end
if attributes.key?(:'updated_at')
self.updated_at = attributes[:'updated_at']
end
if attributes.key?(:'height')
self.height = attributes[:'height']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @access.nil?
invalid_properties.push('invalid value for "access", access cannot be nil.')
end
if @created_at.nil?
invalid_properties.push('invalid value for "created_at", created_at cannot be nil.')
end
if @archived.nil?
invalid_properties.push('invalid value for "archived", archived cannot be nil.')
end
if @id.nil?
invalid_properties.push('invalid value for "id", id cannot be nil.')
end
if @updated_at.nil?
invalid_properties.push('invalid value for "updated_at", updated_at cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @access.nil?
access_validator = EnumAttributeValidator.new('String', ["PUBLIC_INDEXABLE", "PUBLIC_NOT_INDEXABLE", "HIDDEN_INDEXABLE", "HIDDEN_NOT_INDEXABLE", "HIDDEN_PRIVATE", "PRIVATE", "HIDDEN_SENSITIVE", "SENSITIVE"])
return false unless access_validator.valid?(@access)
return false if @created_at.nil?
return false if @archived.nil?
return false if @id.nil?
return false if @updated_at.nil?
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] access Object to be assigned
def access=(access)
validator = EnumAttributeValidator.new('String', ["PUBLIC_INDEXABLE", "PUBLIC_NOT_INDEXABLE", "HIDDEN_INDEXABLE", "HIDDEN_NOT_INDEXABLE", "HIDDEN_PRIVATE", "PRIVATE", "HIDDEN_SENSITIVE", "SENSITIVE"])
unless validator.valid?(access)
fail ArgumentError, "invalid value for \"access\", must be one of #{validator.allowable_values}."
end
@access = access
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
extension == o.extension &&
access == o.access &&
parent_folder_id == o.parent_folder_id &&
source_group == o.source_group &&
file_md5 == o.file_md5 &&
encoding == o.encoding &&
type == o.type &&
is_usable_in_content == o.is_usable_in_content &&
url == o.url &&
expires_at == o.expires_at &&
created_at == o.created_at &&
archived_at == o.archived_at &&
path == o.path &&
archived == o.archived &&
size == o.size &&
name == o.name &&
width == o.width &&
id == o.id &&
default_hosting_url == o.default_hosting_url &&
updated_at == o.updated_at &&
height == o.height
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[extension, access, parent_folder_id, source_group, file_md5, encoding, type, is_usable_in_content, url, expires_at, created_at, archived_at, path, archived, size, name, width, id, default_hosting_url, updated_at, height].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Files.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/files/models/paging.rb | lib/hubspot/codegen/files/models/paging.rb | =begin
#Files
#Upload and manage files.
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Files
class Paging
attr_accessor :_next
attr_accessor :prev
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'_next' => :'next',
:'prev' => :'prev'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'_next' => :'NextPage',
:'prev' => :'PreviousPage'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Files::Paging` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Files::Paging`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'_next')
self._next = attributes[:'_next']
end
if attributes.key?(:'prev')
self.prev = attributes[:'prev']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
_next == o._next &&
prev == o.prev
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[_next, prev].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Files.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/files/models/error_detail.rb | lib/hubspot/codegen/files/models/error_detail.rb | =begin
#Files
#Upload and manage files.
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Files
class ErrorDetail
# A specific category that contains more specific detail about the error
attr_accessor :sub_category
# The status code associated with the error detail
attr_accessor :code
# The name of the field or parameter in which the error was found.
attr_accessor :_in
# Context about the error condition
attr_accessor :context
# A human readable message describing the error along with remediation steps where appropriate
attr_accessor :message
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'sub_category' => :'subCategory',
:'code' => :'code',
:'_in' => :'in',
:'context' => :'context',
:'message' => :'message'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'sub_category' => :'String',
:'code' => :'String',
:'_in' => :'String',
:'context' => :'Hash<String, Array<String>>',
:'message' => :'String'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Files::ErrorDetail` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Files::ErrorDetail`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'sub_category')
self.sub_category = attributes[:'sub_category']
end
if attributes.key?(:'code')
self.code = attributes[:'code']
end
if attributes.key?(:'_in')
self._in = attributes[:'_in']
end
if attributes.key?(:'context')
if (value = attributes[:'context']).is_a?(Hash)
self.context = value
end
end
if attributes.key?(:'message')
self.message = attributes[:'message']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @message.nil?
invalid_properties.push('invalid value for "message", message cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @message.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
sub_category == o.sub_category &&
code == o.code &&
_in == o._in &&
context == o.context &&
message == o.message
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[sub_category, code, _in, context, message].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Files.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/files/models/folder_update_task_locator.rb | lib/hubspot/codegen/files/models/folder_update_task_locator.rb | =begin
#Files
#Upload and manage files.
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Files
# Information on the task that has been started, and where to check it's status.
class FolderUpdateTaskLocator
# Links for where to check information related to the task. The `status` link gives the URL for where to check the status of the task.
attr_accessor :links
# ID of the task
attr_accessor :id
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'links' => :'links',
:'id' => :'id'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'links' => :'Hash<String, String>',
:'id' => :'String'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Files::FolderUpdateTaskLocator` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Files::FolderUpdateTaskLocator`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'links')
if (value = attributes[:'links']).is_a?(Hash)
self.links = value
end
end
if attributes.key?(:'id')
self.id = attributes[:'id']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @links.nil?
invalid_properties.push('invalid value for "links", links cannot be nil.')
end
if @id.nil?
invalid_properties.push('invalid value for "id", id cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @links.nil?
return false if @id.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
links == o.links &&
id == o.id
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[links, id].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Files.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/files/models/file_stat.rb | lib/hubspot/codegen/files/models/file_stat.rb | =begin
#Files
#Upload and manage files.
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Files
class FileStat
attr_accessor :file
attr_accessor :folder
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'file' => :'file',
:'folder' => :'folder'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'file' => :'File',
:'folder' => :'Folder'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Files::FileStat` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Files::FileStat`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'file')
self.file = attributes[:'file']
end
if attributes.key?(:'folder')
self.folder = attributes[:'folder']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
file == o.file &&
folder == o.folder
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[file, folder].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Files.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/files/models/folder.rb | lib/hubspot/codegen/files/models/folder.rb | =begin
#Files
#Upload and manage files.
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Files
class Folder
# Timestamp of folder creation.
attr_accessor :created_at
# Timestamp of folder deletion.
attr_accessor :archived_at
# Path of the folder in the file manager.
attr_accessor :path
# Marks whether the folder is deleted or not.
attr_accessor :archived
# ID of the parent folder.
attr_accessor :parent_folder_id
# Name of the folder.
attr_accessor :name
# ID of the folder.
attr_accessor :id
# Timestamp of the latest update to the folder.
attr_accessor :updated_at
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'created_at' => :'createdAt',
:'archived_at' => :'archivedAt',
:'path' => :'path',
:'archived' => :'archived',
:'parent_folder_id' => :'parentFolderId',
:'name' => :'name',
:'id' => :'id',
:'updated_at' => :'updatedAt'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'created_at' => :'Time',
:'archived_at' => :'Time',
:'path' => :'String',
:'archived' => :'Boolean',
:'parent_folder_id' => :'String',
:'name' => :'String',
:'id' => :'String',
:'updated_at' => :'Time'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Files::Folder` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Files::Folder`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'created_at')
self.created_at = attributes[:'created_at']
end
if attributes.key?(:'archived_at')
self.archived_at = attributes[:'archived_at']
end
if attributes.key?(:'path')
self.path = attributes[:'path']
end
if attributes.key?(:'archived')
self.archived = attributes[:'archived']
end
if attributes.key?(:'parent_folder_id')
self.parent_folder_id = attributes[:'parent_folder_id']
end
if attributes.key?(:'name')
self.name = attributes[:'name']
end
if attributes.key?(:'id')
self.id = attributes[:'id']
end
if attributes.key?(:'updated_at')
self.updated_at = attributes[:'updated_at']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @created_at.nil?
invalid_properties.push('invalid value for "created_at", created_at cannot be nil.')
end
if @archived.nil?
invalid_properties.push('invalid value for "archived", archived cannot be nil.')
end
if @id.nil?
invalid_properties.push('invalid value for "id", id cannot be nil.')
end
if @updated_at.nil?
invalid_properties.push('invalid value for "updated_at", updated_at cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @created_at.nil?
return false if @archived.nil?
return false if @id.nil?
return false if @updated_at.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
created_at == o.created_at &&
archived_at == o.archived_at &&
path == o.path &&
archived == o.archived &&
parent_folder_id == o.parent_folder_id &&
name == o.name &&
id == o.id &&
updated_at == o.updated_at
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[created_at, archived_at, path, archived, parent_folder_id, name, id, updated_at].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Files.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/files/models/folder_update_input.rb | lib/hubspot/codegen/files/models/folder_update_input.rb | =begin
#Files
#Upload and manage files.
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Files
# Object for updating folders.
class FolderUpdateInput
# New parent folderId. If changed, the folder and all it's children will be moved into the specified folder. parentFolderId and parentFolderPath cannot be specified at the same time.
attr_accessor :parent_folder_id
# New name. If specified the folder's name and fullPath will change. All children of the folder will be updated accordingly.
attr_accessor :name
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'parent_folder_id' => :'parentFolderId',
:'name' => :'name'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'parent_folder_id' => :'Integer',
:'name' => :'String'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Files::FolderUpdateInput` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Files::FolderUpdateInput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'parent_folder_id')
self.parent_folder_id = attributes[:'parent_folder_id']
end
if attributes.key?(:'name')
self.name = attributes[:'name']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
parent_folder_id == o.parent_folder_id &&
name == o.name
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[parent_folder_id, name].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Files.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/files/models/import_from_url_task_locator.rb | lib/hubspot/codegen/files/models/import_from_url_task_locator.rb | =begin
#Files
#Upload and manage files.
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Files
# Information on the task that has been started, and where to check it's status.
class ImportFromUrlTaskLocator
# Links for where to check information related to the task. The `status` link gives the URL for where to check the status of the task.
attr_accessor :links
# ID of the task
attr_accessor :id
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'links' => :'links',
:'id' => :'id'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'links' => :'Hash<String, String>',
:'id' => :'String'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Files::ImportFromUrlTaskLocator` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Files::ImportFromUrlTaskLocator`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'links')
if (value = attributes[:'links']).is_a?(Hash)
self.links = value
end
end
if attributes.key?(:'id')
self.id = attributes[:'id']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @links.nil?
invalid_properties.push('invalid value for "links", links cannot be nil.')
end
if @id.nil?
invalid_properties.push('invalid value for "id", id cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @links.nil?
return false if @id.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
links == o.links &&
id == o.id
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[links, id].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Files.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/files/models/collection_response_file.rb | lib/hubspot/codegen/files/models/collection_response_file.rb | =begin
#Files
#Upload and manage files.
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Files
# Collections of files
class CollectionResponseFile
attr_accessor :paging
#
attr_accessor :results
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'paging' => :'paging',
:'results' => :'results'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'paging' => :'Paging',
:'results' => :'Array<File>'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Files::CollectionResponseFile` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Files::CollectionResponseFile`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'paging')
self.paging = attributes[:'paging']
end
if attributes.key?(:'results')
if (value = attributes[:'results']).is_a?(Array)
self.results = value
end
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @results.nil?
invalid_properties.push('invalid value for "results", results cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @results.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
paging == o.paging &&
results == o.results
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[paging, results].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Files.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/files/models/file_update_input.rb | lib/hubspot/codegen/files/models/file_update_input.rb | =begin
#Files
#Upload and manage files.
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Files
# Object for updating files.
class FileUpdateInput
# NONE: Do not run any duplicate validation. REJECT: Reject the upload if a duplicate is found. RETURN_EXISTING: If a duplicate file is found, do not upload a new file and return the found duplicate instead.
attr_accessor :access
# FolderId where the file should be moved to. folderId and folderPath parameters cannot be set at the same time.
attr_accessor :parent_folder_id
# New name for the file.
attr_accessor :name
# Folder path where the file should be moved to. folderId and folderPath parameters cannot be set at the same time.
attr_accessor :parent_folder_path
attr_accessor :clear_expires
# Mark whether the file should be used in new content or not.
attr_accessor :is_usable_in_content
attr_accessor :expires_at
class EnumAttributeValidator
attr_reader :datatype
attr_reader :allowable_values
def initialize(datatype, allowable_values)
@allowable_values = allowable_values.map do |value|
case datatype.to_s
when /Integer/i
value.to_i
when /Float/i
value.to_f
else
value
end
end
end
def valid?(value)
!value || allowable_values.include?(value)
end
end
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'access' => :'access',
:'parent_folder_id' => :'parentFolderId',
:'name' => :'name',
:'parent_folder_path' => :'parentFolderPath',
:'clear_expires' => :'clearExpires',
:'is_usable_in_content' => :'isUsableInContent',
:'expires_at' => :'expiresAt'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'access' => :'String',
:'parent_folder_id' => :'String',
:'name' => :'String',
:'parent_folder_path' => :'String',
:'clear_expires' => :'Boolean',
:'is_usable_in_content' => :'Boolean',
:'expires_at' => :'Time'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Files::FileUpdateInput` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Files::FileUpdateInput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'access')
self.access = attributes[:'access']
end
if attributes.key?(:'parent_folder_id')
self.parent_folder_id = attributes[:'parent_folder_id']
end
if attributes.key?(:'name')
self.name = attributes[:'name']
end
if attributes.key?(:'parent_folder_path')
self.parent_folder_path = attributes[:'parent_folder_path']
end
if attributes.key?(:'clear_expires')
self.clear_expires = attributes[:'clear_expires']
end
if attributes.key?(:'is_usable_in_content')
self.is_usable_in_content = attributes[:'is_usable_in_content']
end
if attributes.key?(:'expires_at')
self.expires_at = attributes[:'expires_at']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
access_validator = EnumAttributeValidator.new('String', ["PUBLIC_INDEXABLE", "PUBLIC_NOT_INDEXABLE", "HIDDEN_INDEXABLE", "HIDDEN_NOT_INDEXABLE", "HIDDEN_PRIVATE", "PRIVATE", "HIDDEN_SENSITIVE", "SENSITIVE"])
return false unless access_validator.valid?(@access)
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] access Object to be assigned
def access=(access)
validator = EnumAttributeValidator.new('String', ["PUBLIC_INDEXABLE", "PUBLIC_NOT_INDEXABLE", "HIDDEN_INDEXABLE", "HIDDEN_NOT_INDEXABLE", "HIDDEN_PRIVATE", "PRIVATE", "HIDDEN_SENSITIVE", "SENSITIVE"])
unless validator.valid?(access)
fail ArgumentError, "invalid value for \"access\", must be one of #{validator.allowable_values}."
end
@access = access
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
access == o.access &&
parent_folder_id == o.parent_folder_id &&
name == o.name &&
parent_folder_path == o.parent_folder_path &&
clear_expires == o.clear_expires &&
is_usable_in_content == o.is_usable_in_content &&
expires_at == o.expires_at
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[access, parent_folder_id, name, parent_folder_path, clear_expires, is_usable_in_content, expires_at].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Files.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/files/models/file_action_response.rb | lib/hubspot/codegen/files/models/file_action_response.rb | =begin
#Files
#Upload and manage files.
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Files
class FileActionResponse
attr_accessor :result
# Time of completion of task.
attr_accessor :completed_at
# Number of errors resulting from the task.
attr_accessor :num_errors
# Timestamp of when the task was requested.
attr_accessor :requested_at
# Timestamp of when the task was started.
attr_accessor :started_at
# Link to check the status of the requested task.
attr_accessor :links
# Descriptive error messages.
attr_accessor :errors
# ID of the requested task.
attr_accessor :task_id
# Current status of the task.
attr_accessor :status
class EnumAttributeValidator
attr_reader :datatype
attr_reader :allowable_values
def initialize(datatype, allowable_values)
@allowable_values = allowable_values.map do |value|
case datatype.to_s
when /Integer/i
value.to_i
when /Float/i
value.to_f
else
value
end
end
end
def valid?(value)
!value || allowable_values.include?(value)
end
end
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'result' => :'result',
:'completed_at' => :'completedAt',
:'num_errors' => :'numErrors',
:'requested_at' => :'requestedAt',
:'started_at' => :'startedAt',
:'links' => :'links',
:'errors' => :'errors',
:'task_id' => :'taskId',
:'status' => :'status'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'result' => :'File',
:'completed_at' => :'Time',
:'num_errors' => :'Integer',
:'requested_at' => :'Time',
:'started_at' => :'Time',
:'links' => :'Hash<String, String>',
:'errors' => :'Array<StandardError>',
:'task_id' => :'String',
:'status' => :'String'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Files::FileActionResponse` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Files::FileActionResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'result')
self.result = attributes[:'result']
end
if attributes.key?(:'completed_at')
self.completed_at = attributes[:'completed_at']
end
if attributes.key?(:'num_errors')
self.num_errors = attributes[:'num_errors']
end
if attributes.key?(:'requested_at')
self.requested_at = attributes[:'requested_at']
end
if attributes.key?(:'started_at')
self.started_at = attributes[:'started_at']
end
if attributes.key?(:'links')
if (value = attributes[:'links']).is_a?(Hash)
self.links = value
end
end
if attributes.key?(:'errors')
if (value = attributes[:'errors']).is_a?(Array)
self.errors = value
end
end
if attributes.key?(:'task_id')
self.task_id = attributes[:'task_id']
end
if attributes.key?(:'status')
self.status = attributes[:'status']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @completed_at.nil?
invalid_properties.push('invalid value for "completed_at", completed_at cannot be nil.')
end
if @started_at.nil?
invalid_properties.push('invalid value for "started_at", started_at cannot be nil.')
end
if @task_id.nil?
invalid_properties.push('invalid value for "task_id", task_id cannot be nil.')
end
if @status.nil?
invalid_properties.push('invalid value for "status", status cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @completed_at.nil?
return false if @started_at.nil?
return false if @task_id.nil?
return false if @status.nil?
status_validator = EnumAttributeValidator.new('String', ["PENDING", "PROCESSING", "CANCELED", "COMPLETE"])
return false unless status_validator.valid?(@status)
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] status Object to be assigned
def status=(status)
validator = EnumAttributeValidator.new('String', ["PENDING", "PROCESSING", "CANCELED", "COMPLETE"])
unless validator.valid?(status)
fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
end
@status = status
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
result == o.result &&
completed_at == o.completed_at &&
num_errors == o.num_errors &&
requested_at == o.requested_at &&
started_at == o.started_at &&
links == o.links &&
errors == o.errors &&
task_id == o.task_id &&
status == o.status
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[result, completed_at, num_errors, requested_at, started_at, links, errors, task_id, status].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Files.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/files/models/collection_response_folder.rb | lib/hubspot/codegen/files/models/collection_response_folder.rb | =begin
#Files
#Upload and manage files.
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Files
class CollectionResponseFolder
attr_accessor :paging
#
attr_accessor :results
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'paging' => :'paging',
:'results' => :'results'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'paging' => :'Paging',
:'results' => :'Array<Folder>'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Files::CollectionResponseFolder` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Files::CollectionResponseFolder`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'paging')
self.paging = attributes[:'paging']
end
if attributes.key?(:'results')
if (value = attributes[:'results']).is_a?(Array)
self.results = value
end
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @results.nil?
invalid_properties.push('invalid value for "results", results cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @results.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
paging == o.paging &&
results == o.results
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[paging, results].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Files.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/files/models/error.rb | lib/hubspot/codegen/files/models/error.rb | =begin
#Files
#Upload and manage files.
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Files
class Error
# A specific category that contains more specific detail about the error
attr_accessor :sub_category
# Context about the error condition
attr_accessor :context
# A unique identifier for the request. Include this value with any error reports or support tickets
attr_accessor :correlation_id
# A map of link names to associated URIs containing documentation about the error or recommended remediation steps
attr_accessor :links
# A human readable message describing the error along with remediation steps where appropriate
attr_accessor :message
# The error category
attr_accessor :category
# further information about the error
attr_accessor :errors
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'sub_category' => :'subCategory',
:'context' => :'context',
:'correlation_id' => :'correlationId',
:'links' => :'links',
:'message' => :'message',
:'category' => :'category',
:'errors' => :'errors'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'sub_category' => :'String',
:'context' => :'Hash<String, Array<String>>',
:'correlation_id' => :'String',
:'links' => :'Hash<String, String>',
:'message' => :'String',
:'category' => :'String',
:'errors' => :'Array<ErrorDetail>'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Files::Error` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Files::Error`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'sub_category')
self.sub_category = attributes[:'sub_category']
end
if attributes.key?(:'context')
if (value = attributes[:'context']).is_a?(Hash)
self.context = value
end
end
if attributes.key?(:'correlation_id')
self.correlation_id = attributes[:'correlation_id']
end
if attributes.key?(:'links')
if (value = attributes[:'links']).is_a?(Hash)
self.links = value
end
end
if attributes.key?(:'message')
self.message = attributes[:'message']
end
if attributes.key?(:'category')
self.category = attributes[:'category']
end
if attributes.key?(:'errors')
if (value = attributes[:'errors']).is_a?(Array)
self.errors = value
end
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @correlation_id.nil?
invalid_properties.push('invalid value for "correlation_id", correlation_id cannot be nil.')
end
if @message.nil?
invalid_properties.push('invalid value for "message", message cannot be nil.')
end
if @category.nil?
invalid_properties.push('invalid value for "category", category cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @correlation_id.nil?
return false if @message.nil?
return false if @category.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
sub_category == o.sub_category &&
context == o.context &&
correlation_id == o.correlation_id &&
links == o.links &&
message == o.message &&
category == o.category &&
errors == o.errors
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[sub_category, context, correlation_id, links, message, category, errors].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Files.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/files/models/import_from_url_input.rb | lib/hubspot/codegen/files/models/import_from_url_input.rb | =begin
#Files
#Upload and manage files.
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Files
class ImportFromUrlInput
# One of folderPath or folderId is required. Destination folder path for the uploaded file. If the folder path does not exist, there will be an attempt to create the folder path.
attr_accessor :folder_path
# PUBLIC_INDEXABLE: File is publicly accessible by anyone who has the URL. Search engines can index the file. PUBLIC_NOT_INDEXABLE: File is publicly accessible by anyone who has the URL. Search engines *can't* index the file. PRIVATE: File is NOT publicly accessible. Requires a signed URL to see content. Search engines *can't* index the file.
attr_accessor :access
# ENTIRE_PORTAL: Look for a duplicate file in the entire account. EXACT_FOLDER: Look for a duplicate file in the provided folder.
attr_accessor :duplicate_validation_scope
# Name to give the resulting file in the file manager.
attr_accessor :name
# NONE: Do not run any duplicate validation. REJECT: Reject the upload if a duplicate is found. RETURN_EXISTING: If a duplicate file is found, do not upload a new file and return the found duplicate instead.
attr_accessor :duplicate_validation_strategy
# Time to live. If specified the file will be deleted after the given time frame. If left unset, the file will exist indefinitely
attr_accessor :ttl
# If true, will overwrite existing file if one with the same name and extension exists in the given folder. The overwritten file will be deleted and the uploaded file will take its place with a new ID. If unset or set as false, the new file's name will be updated to prevent colliding with existing file if one exists with the same path, name, and extension
attr_accessor :overwrite
attr_accessor :expires_at
# URL to download the new file from.
attr_accessor :url
# One of folderId or folderPath is required. Destination folderId for the uploaded file.
attr_accessor :folder_id
class EnumAttributeValidator
attr_reader :datatype
attr_reader :allowable_values
def initialize(datatype, allowable_values)
@allowable_values = allowable_values.map do |value|
case datatype.to_s
when /Integer/i
value.to_i
when /Float/i
value.to_f
else
value
end
end
end
def valid?(value)
!value || allowable_values.include?(value)
end
end
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'folder_path' => :'folderPath',
:'access' => :'access',
:'duplicate_validation_scope' => :'duplicateValidationScope',
:'name' => :'name',
:'duplicate_validation_strategy' => :'duplicateValidationStrategy',
:'ttl' => :'ttl',
:'overwrite' => :'overwrite',
:'expires_at' => :'expiresAt',
:'url' => :'url',
:'folder_id' => :'folderId'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'folder_path' => :'String',
:'access' => :'String',
:'duplicate_validation_scope' => :'String',
:'name' => :'String',
:'duplicate_validation_strategy' => :'String',
:'ttl' => :'String',
:'overwrite' => :'Boolean',
:'expires_at' => :'Time',
:'url' => :'String',
:'folder_id' => :'String'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Files::ImportFromUrlInput` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Files::ImportFromUrlInput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'folder_path')
self.folder_path = attributes[:'folder_path']
end
if attributes.key?(:'access')
self.access = attributes[:'access']
end
if attributes.key?(:'duplicate_validation_scope')
self.duplicate_validation_scope = attributes[:'duplicate_validation_scope']
end
if attributes.key?(:'name')
self.name = attributes[:'name']
end
if attributes.key?(:'duplicate_validation_strategy')
self.duplicate_validation_strategy = attributes[:'duplicate_validation_strategy']
end
if attributes.key?(:'ttl')
self.ttl = attributes[:'ttl']
end
if attributes.key?(:'overwrite')
self.overwrite = attributes[:'overwrite']
end
if attributes.key?(:'expires_at')
self.expires_at = attributes[:'expires_at']
end
if attributes.key?(:'url')
self.url = attributes[:'url']
end
if attributes.key?(:'folder_id')
self.folder_id = attributes[:'folder_id']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @access.nil?
invalid_properties.push('invalid value for "access", access cannot be nil.')
end
if @url.nil?
invalid_properties.push('invalid value for "url", url cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @access.nil?
access_validator = EnumAttributeValidator.new('String', ["PUBLIC_INDEXABLE", "PUBLIC_NOT_INDEXABLE", "HIDDEN_INDEXABLE", "HIDDEN_NOT_INDEXABLE", "HIDDEN_PRIVATE", "PRIVATE", "HIDDEN_SENSITIVE", "SENSITIVE"])
return false unless access_validator.valid?(@access)
duplicate_validation_scope_validator = EnumAttributeValidator.new('String', ["ENTIRE_PORTAL", "EXACT_FOLDER"])
return false unless duplicate_validation_scope_validator.valid?(@duplicate_validation_scope)
duplicate_validation_strategy_validator = EnumAttributeValidator.new('String', ["NONE", "REJECT", "RETURN_EXISTING"])
return false unless duplicate_validation_strategy_validator.valid?(@duplicate_validation_strategy)
return false if @url.nil?
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] access Object to be assigned
def access=(access)
validator = EnumAttributeValidator.new('String', ["PUBLIC_INDEXABLE", "PUBLIC_NOT_INDEXABLE", "HIDDEN_INDEXABLE", "HIDDEN_NOT_INDEXABLE", "HIDDEN_PRIVATE", "PRIVATE", "HIDDEN_SENSITIVE", "SENSITIVE"])
unless validator.valid?(access)
fail ArgumentError, "invalid value for \"access\", must be one of #{validator.allowable_values}."
end
@access = access
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] duplicate_validation_scope Object to be assigned
def duplicate_validation_scope=(duplicate_validation_scope)
validator = EnumAttributeValidator.new('String', ["ENTIRE_PORTAL", "EXACT_FOLDER"])
unless validator.valid?(duplicate_validation_scope)
fail ArgumentError, "invalid value for \"duplicate_validation_scope\", must be one of #{validator.allowable_values}."
end
@duplicate_validation_scope = duplicate_validation_scope
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] duplicate_validation_strategy Object to be assigned
def duplicate_validation_strategy=(duplicate_validation_strategy)
validator = EnumAttributeValidator.new('String', ["NONE", "REJECT", "RETURN_EXISTING"])
unless validator.valid?(duplicate_validation_strategy)
fail ArgumentError, "invalid value for \"duplicate_validation_strategy\", must be one of #{validator.allowable_values}."
end
@duplicate_validation_strategy = duplicate_validation_strategy
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
folder_path == o.folder_path &&
access == o.access &&
duplicate_validation_scope == o.duplicate_validation_scope &&
name == o.name &&
duplicate_validation_strategy == o.duplicate_validation_strategy &&
ttl == o.ttl &&
overwrite == o.overwrite &&
expires_at == o.expires_at &&
url == o.url &&
folder_id == o.folder_id
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[folder_path, access, duplicate_validation_scope, name, duplicate_validation_strategy, ttl, overwrite, expires_at, url, folder_id].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Files.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/files/api/folders_api.rb | lib/hubspot/codegen/files/api/folders_api.rb | =begin
#Files
#Upload and manage files.
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'cgi'
module Hubspot
module Files
class FoldersApi
attr_accessor :api_client
def initialize(api_client = ApiClient.default)
@api_client = api_client
end
# Delete folder by ID
# Delete folder by ID.
# @param folder_id [String] ID of folder to delete.
# @param [Hash] opts the optional parameters
# @return [nil]
def archive(folder_id, opts = {})
archive_with_http_info(folder_id, opts)
nil
end
# Delete folder by ID
# Delete folder by ID.
# @param folder_id [String] ID of folder to delete.
# @param [Hash] opts the optional parameters
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
def archive_with_http_info(folder_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FoldersApi.archive ...'
end
# verify the required parameter 'folder_id' is set
if @api_client.config.client_side_validation && folder_id.nil?
fail ArgumentError, "Missing the required parameter 'folder_id' when calling FoldersApi.archive"
end
pattern = Regexp.new(/\d+/)
if @api_client.config.client_side_validation && folder_id !~ pattern
fail ArgumentError, "invalid value for 'folder_id' when calling FoldersApi.archive, must conform to the pattern #{pattern}."
end
# resource path
local_var_path = '/files/v3/folders/{folderId}'.sub('{' + 'folderId' + '}', CGI.escape(folder_id.to_s))
# query parameters
query_params = opts[:query_params] || {}
# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['*/*'])
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body]
# return_type
return_type = opts[:debug_return_type]
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"FoldersApi.archive",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: FoldersApi#archive\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Delete folder by path
# Delete a folder, identified by its path.
# @param folder_path [String] Path of folder to delete
# @param [Hash] opts the optional parameters
# @return [nil]
def archive_by_path(folder_path, opts = {})
archive_by_path_with_http_info(folder_path, opts)
nil
end
# Delete folder by path
# Delete a folder, identified by its path.
# @param folder_path [String] Path of folder to delete
# @param [Hash] opts the optional parameters
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
def archive_by_path_with_http_info(folder_path, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FoldersApi.archive_by_path ...'
end
# verify the required parameter 'folder_path' is set
if @api_client.config.client_side_validation && folder_path.nil?
fail ArgumentError, "Missing the required parameter 'folder_path' when calling FoldersApi.archive_by_path"
end
pattern = Regexp.new(/.+/)
if @api_client.config.client_side_validation && folder_path !~ pattern
fail ArgumentError, "invalid value for 'folder_path' when calling FoldersApi.archive_by_path, must conform to the pattern #{pattern}."
end
# resource path
local_var_path = '/files/v3/folders/{folderPath}'.sub('{' + 'folderPath' + '}', CGI.escape(folder_path.to_s))
# query parameters
query_params = opts[:query_params] || {}
# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['*/*'])
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body]
# return_type
return_type = opts[:debug_return_type]
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"FoldersApi.archive_by_path",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: FoldersApi#archive_by_path\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Check folder update status
# Check status of folder update. Folder updates happen asynchronously.
# @param task_id [String] The ID of the folder update task.
# @param [Hash] opts the optional parameters
# @return [FolderActionResponse]
def check_update_status(task_id, opts = {})
data, _status_code, _headers = check_update_status_with_http_info(task_id, opts)
data
end
# Check folder update status
# Check status of folder update. Folder updates happen asynchronously.
# @param task_id [String] The ID of the folder update task.
# @param [Hash] opts the optional parameters
# @return [Array<(FolderActionResponse, Integer, Hash)>] FolderActionResponse data, response status code and response headers
def check_update_status_with_http_info(task_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FoldersApi.check_update_status ...'
end
# verify the required parameter 'task_id' is set
if @api_client.config.client_side_validation && task_id.nil?
fail ArgumentError, "Missing the required parameter 'task_id' when calling FoldersApi.check_update_status"
end
# resource path
local_var_path = '/files/v3/folders/update/async/tasks/{taskId}/status'.sub('{' + 'taskId' + '}', CGI.escape(task_id.to_s))
# query parameters
query_params = opts[:query_params] || {}
# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body]
# return_type
return_type = opts[:debug_return_type] || 'FolderActionResponse'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"FoldersApi.check_update_status",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: FoldersApi#check_update_status\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Create folder
# Creates a folder.
# @param folder_input [FolderInput] Folder creation options
# @param [Hash] opts the optional parameters
# @return [Folder]
def create(folder_input, opts = {})
data, _status_code, _headers = create_with_http_info(folder_input, opts)
data
end
# Create folder
# Creates a folder.
# @param folder_input [FolderInput] Folder creation options
# @param [Hash] opts the optional parameters
# @return [Array<(Folder, Integer, Hash)>] Folder data, response status code and response headers
def create_with_http_info(folder_input, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FoldersApi.create ...'
end
# verify the required parameter 'folder_input' is set
if @api_client.config.client_side_validation && folder_input.nil?
fail ArgumentError, "Missing the required parameter 'folder_input' when calling FoldersApi.create"
end
# resource path
local_var_path = '/files/v3/folders'
# query parameters
query_params = opts[:query_params] || {}
# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])
# HTTP header 'Content-Type'
content_type = @api_client.select_header_content_type(['application/json'])
if !content_type.nil?
header_params['Content-Type'] = content_type
end
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body] || @api_client.object_to_http_body(folder_input)
# return_type
return_type = opts[:debug_return_type] || 'Folder'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"FoldersApi.create",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: FoldersApi#create\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Search folders
# Search for folders. Does not contain hidden or archived folders.
# @param [Hash] opts the optional parameters
# @option opts [Array<String>] :properties Properties that should be included in the returned folders.
# @option opts [String] :after Offset search results by this value. The default offset is 0 and the maximum offset of items for a given search is 10,000. Narrow your search down if you are reaching this limit.
# @option opts [String] :before
# @option opts [Integer] :limit Number of items to return. Default limit is 10, maximum limit is 100.
# @option opts [Array<String>] :sort Sort results by given property. For example -name sorts by name field descending, name sorts by name field ascending.
# @option opts [Array<Integer>] :ids
# @option opts [Integer] :id_lte
# @option opts [Integer] :id_gte
# @option opts [Time] :created_at Search folders by exact time of creation. Time must be epoch time in milliseconds.
# @option opts [Time] :created_at_lte Search folders by less than or equal to time of creation. Can be used with createdAtGte to create a range.
# @option opts [Time] :created_at_gte Search folders by greater than or equal to time of creation. Can be used with createdAtLte to create a range.
# @option opts [Time] :updated_at Search folders by exact time of latest updated. Time must be epoch time in milliseconds.
# @option opts [Time] :updated_at_lte Search folders by less than or equal to time of latest update. Can be used with updatedAtGte to create a range.
# @option opts [Time] :updated_at_gte Search folders by greater than or equal to time of latest update. Can be used with updatedAtLte to create a range.
# @option opts [String] :name Search for folders containing the specified name.
# @option opts [String] :path Search folders by path.
# @option opts [Array<Integer>] :parent_folder_ids Search folders with the given parent folderId.
# @return [CollectionResponseFolder]
def do_search(opts = {})
data, _status_code, _headers = do_search_with_http_info(opts)
data
end
# Search folders
# Search for folders. Does not contain hidden or archived folders.
# @param [Hash] opts the optional parameters
# @option opts [Array<String>] :properties Properties that should be included in the returned folders.
# @option opts [String] :after Offset search results by this value. The default offset is 0 and the maximum offset of items for a given search is 10,000. Narrow your search down if you are reaching this limit.
# @option opts [String] :before
# @option opts [Integer] :limit Number of items to return. Default limit is 10, maximum limit is 100.
# @option opts [Array<String>] :sort Sort results by given property. For example -name sorts by name field descending, name sorts by name field ascending.
# @option opts [Array<Integer>] :ids
# @option opts [Integer] :id_lte
# @option opts [Integer] :id_gte
# @option opts [Time] :created_at Search folders by exact time of creation. Time must be epoch time in milliseconds.
# @option opts [Time] :created_at_lte Search folders by less than or equal to time of creation. Can be used with createdAtGte to create a range.
# @option opts [Time] :created_at_gte Search folders by greater than or equal to time of creation. Can be used with createdAtLte to create a range.
# @option opts [Time] :updated_at Search folders by exact time of latest updated. Time must be epoch time in milliseconds.
# @option opts [Time] :updated_at_lte Search folders by less than or equal to time of latest update. Can be used with updatedAtGte to create a range.
# @option opts [Time] :updated_at_gte Search folders by greater than or equal to time of latest update. Can be used with updatedAtLte to create a range.
# @option opts [String] :name Search for folders containing the specified name.
# @option opts [String] :path Search folders by path.
# @option opts [Array<Integer>] :parent_folder_ids Search folders with the given parent folderId.
# @return [Array<(CollectionResponseFolder, Integer, Hash)>] CollectionResponseFolder data, response status code and response headers
def do_search_with_http_info(opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FoldersApi.do_search ...'
end
# resource path
local_var_path = '/files/v3/folders/search'
# query parameters
query_params = opts[:query_params] || {}
query_params[:'properties'] = @api_client.build_collection_param(opts[:'properties'], :csv) if !opts[:'properties'].nil?
query_params[:'after'] = opts[:'after'] if !opts[:'after'].nil?
query_params[:'before'] = opts[:'before'] if !opts[:'before'].nil?
query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
query_params[:'sort'] = @api_client.build_collection_param(opts[:'sort'], :multi) if !opts[:'sort'].nil?
query_params[:'ids'] = @api_client.build_collection_param(opts[:'ids'], :multi) if !opts[:'ids'].nil?
query_params[:'idLte'] = opts[:'id_lte'] if !opts[:'id_lte'].nil?
query_params[:'idGte'] = opts[:'id_gte'] if !opts[:'id_gte'].nil?
query_params[:'createdAt'] = opts[:'created_at'] if !opts[:'created_at'].nil?
query_params[:'createdAtLte'] = opts[:'created_at_lte'] if !opts[:'created_at_lte'].nil?
query_params[:'createdAtGte'] = opts[:'created_at_gte'] if !opts[:'created_at_gte'].nil?
query_params[:'updatedAt'] = opts[:'updated_at'] if !opts[:'updated_at'].nil?
query_params[:'updatedAtLte'] = opts[:'updated_at_lte'] if !opts[:'updated_at_lte'].nil?
query_params[:'updatedAtGte'] = opts[:'updated_at_gte'] if !opts[:'updated_at_gte'].nil?
query_params[:'name'] = opts[:'name'] if !opts[:'name'].nil?
query_params[:'path'] = opts[:'path'] if !opts[:'path'].nil?
query_params[:'parentFolderIds'] = @api_client.build_collection_param(opts[:'parent_folder_ids'], :multi) if !opts[:'parent_folder_ids'].nil?
# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body]
# return_type
return_type = opts[:debug_return_type] || 'CollectionResponseFolder'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"FoldersApi.do_search",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: FoldersApi#do_search\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Retrieve folder by ID
# Retrieve a folder by its ID.
# @param folder_id [String] ID of desired folder
# @param [Hash] opts the optional parameters
# @option opts [Array<String>] :properties Properties to set on returned folder.
# @return [Folder]
def get_by_id(folder_id, opts = {})
data, _status_code, _headers = get_by_id_with_http_info(folder_id, opts)
data
end
# Retrieve folder by ID
# Retrieve a folder by its ID.
# @param folder_id [String] ID of desired folder
# @param [Hash] opts the optional parameters
# @option opts [Array<String>] :properties Properties to set on returned folder.
# @return [Array<(Folder, Integer, Hash)>] Folder data, response status code and response headers
def get_by_id_with_http_info(folder_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FoldersApi.get_by_id ...'
end
# verify the required parameter 'folder_id' is set
if @api_client.config.client_side_validation && folder_id.nil?
fail ArgumentError, "Missing the required parameter 'folder_id' when calling FoldersApi.get_by_id"
end
pattern = Regexp.new(/\d+/)
if @api_client.config.client_side_validation && folder_id !~ pattern
fail ArgumentError, "invalid value for 'folder_id' when calling FoldersApi.get_by_id, must conform to the pattern #{pattern}."
end
# resource path
local_var_path = '/files/v3/folders/{folderId}'.sub('{' + 'folderId' + '}', CGI.escape(folder_id.to_s))
# query parameters
query_params = opts[:query_params] || {}
query_params[:'properties'] = @api_client.build_collection_param(opts[:'properties'], :csv) if !opts[:'properties'].nil?
# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body]
# return_type
return_type = opts[:debug_return_type] || 'Folder'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"FoldersApi.get_by_id",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: FoldersApi#get_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Retrieve folder by path
# Retrieve a folder, identified by its path.
# @param folder_path [String] Path of desired folder.
# @param [Hash] opts the optional parameters
# @option opts [Array<String>] :properties Properties to set on returned folder.
# @return [Folder]
def get_by_path(folder_path, opts = {})
data, _status_code, _headers = get_by_path_with_http_info(folder_path, opts)
data
end
# Retrieve folder by path
# Retrieve a folder, identified by its path.
# @param folder_path [String] Path of desired folder.
# @param [Hash] opts the optional parameters
# @option opts [Array<String>] :properties Properties to set on returned folder.
# @return [Array<(Folder, Integer, Hash)>] Folder data, response status code and response headers
def get_by_path_with_http_info(folder_path, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FoldersApi.get_by_path ...'
end
# verify the required parameter 'folder_path' is set
if @api_client.config.client_side_validation && folder_path.nil?
fail ArgumentError, "Missing the required parameter 'folder_path' when calling FoldersApi.get_by_path"
end
pattern = Regexp.new(/.+/)
if @api_client.config.client_side_validation && folder_path !~ pattern
fail ArgumentError, "invalid value for 'folder_path' when calling FoldersApi.get_by_path, must conform to the pattern #{pattern}."
end
# resource path
local_var_path = '/files/v3/folders/{folderPath}'.sub('{' + 'folderPath' + '}', CGI.escape(folder_path.to_s))
# query parameters
query_params = opts[:query_params] || {}
query_params[:'properties'] = @api_client.build_collection_param(opts[:'properties'], :csv) if !opts[:'properties'].nil?
# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body]
# return_type
return_type = opts[:debug_return_type] || 'Folder'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"FoldersApi.get_by_path",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: FoldersApi#get_by_path\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Update folder properties by folder ID
# Update a folder's properties, identified by folder ID.
# @param folder_id [String] ID of folder to update
# @param folder_update_input [FolderUpdateInput]
# @param [Hash] opts the optional parameters
# @return [Folder]
def update_properties(folder_id, folder_update_input, opts = {})
data, _status_code, _headers = update_properties_with_http_info(folder_id, folder_update_input, opts)
data
end
# Update folder properties by folder ID
# Update a folder's properties, identified by folder ID.
# @param folder_id [String] ID of folder to update
# @param folder_update_input [FolderUpdateInput]
# @param [Hash] opts the optional parameters
# @return [Array<(Folder, Integer, Hash)>] Folder data, response status code and response headers
def update_properties_with_http_info(folder_id, folder_update_input, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FoldersApi.update_properties ...'
end
# verify the required parameter 'folder_id' is set
if @api_client.config.client_side_validation && folder_id.nil?
fail ArgumentError, "Missing the required parameter 'folder_id' when calling FoldersApi.update_properties"
end
pattern = Regexp.new(/\d+/)
if @api_client.config.client_side_validation && folder_id !~ pattern
fail ArgumentError, "invalid value for 'folder_id' when calling FoldersApi.update_properties, must conform to the pattern #{pattern}."
end
# verify the required parameter 'folder_update_input' is set
if @api_client.config.client_side_validation && folder_update_input.nil?
fail ArgumentError, "Missing the required parameter 'folder_update_input' when calling FoldersApi.update_properties"
end
# resource path
local_var_path = '/files/v3/folders/{folderId}'.sub('{' + 'folderId' + '}', CGI.escape(folder_id.to_s))
# query parameters
query_params = opts[:query_params] || {}
# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])
# HTTP header 'Content-Type'
content_type = @api_client.select_header_content_type(['application/json'])
if !content_type.nil?
header_params['Content-Type'] = content_type
end
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body] || @api_client.object_to_http_body(folder_update_input)
# return_type
return_type = opts[:debug_return_type] || 'Folder'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"FoldersApi.update_properties",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: FoldersApi#update_properties\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Update folder properties
# Update properties of folder by given ID. This action happens asynchronously and will update all of the folder's children as well.
# @param folder_update_input_with_id [FolderUpdateInputWithId]
# @param [Hash] opts the optional parameters
# @return [FolderUpdateTaskLocator]
def update_properties_recursively(folder_update_input_with_id, opts = {})
data, _status_code, _headers = update_properties_recursively_with_http_info(folder_update_input_with_id, opts)
data
end
# Update folder properties
# Update properties of folder by given ID. This action happens asynchronously and will update all of the folder's children as well.
# @param folder_update_input_with_id [FolderUpdateInputWithId]
# @param [Hash] opts the optional parameters
# @return [Array<(FolderUpdateTaskLocator, Integer, Hash)>] FolderUpdateTaskLocator data, response status code and response headers
def update_properties_recursively_with_http_info(folder_update_input_with_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FoldersApi.update_properties_recursively ...'
end
# verify the required parameter 'folder_update_input_with_id' is set
if @api_client.config.client_side_validation && folder_update_input_with_id.nil?
fail ArgumentError, "Missing the required parameter 'folder_update_input_with_id' when calling FoldersApi.update_properties_recursively"
end
# resource path
local_var_path = '/files/v3/folders/update/async'
# query parameters
query_params = opts[:query_params] || {}
# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])
# HTTP header 'Content-Type'
content_type = @api_client.select_header_content_type(['application/json'])
if !content_type.nil?
header_params['Content-Type'] = content_type
end
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body] || @api_client.object_to_http_body(folder_update_input_with_id)
# return_type
return_type = opts[:debug_return_type] || 'FolderUpdateTaskLocator'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"FoldersApi.update_properties_recursively",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: FoldersApi#update_properties_recursively\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/files/api/files_api.rb | lib/hubspot/codegen/files/api/files_api.rb | =begin
#Files
#Upload and manage files.
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'cgi'
module Hubspot
module Files
class FilesApi
attr_accessor :api_client
def initialize(api_client = ApiClient.default)
@api_client = api_client
end
# Delete file by ID
# Delete a file by ID
# @param file_id [String] FileId to delete
# @param [Hash] opts the optional parameters
# @return [nil]
def archive(file_id, opts = {})
archive_with_http_info(file_id, opts)
nil
end
# Delete file by ID
# Delete a file by ID
# @param file_id [String] FileId to delete
# @param [Hash] opts the optional parameters
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
def archive_with_http_info(file_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FilesApi.archive ...'
end
# verify the required parameter 'file_id' is set
if @api_client.config.client_side_validation && file_id.nil?
fail ArgumentError, "Missing the required parameter 'file_id' when calling FilesApi.archive"
end
pattern = Regexp.new(/\d+/)
if @api_client.config.client_side_validation && file_id !~ pattern
fail ArgumentError, "invalid value for 'file_id' when calling FilesApi.archive, must conform to the pattern #{pattern}."
end
# resource path
local_var_path = '/files/v3/files/{fileId}'.sub('{' + 'fileId' + '}', CGI.escape(file_id.to_s))
# query parameters
query_params = opts[:query_params] || {}
# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['*/*'])
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body]
# return_type
return_type = opts[:debug_return_type]
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"FilesApi.archive",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: FilesApi#archive\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Check import status
# Check the status of requested import.
# @param task_id [String] Import by URL task ID
# @param [Hash] opts the optional parameters
# @return [FileActionResponse]
def check_import(task_id, opts = {})
data, _status_code, _headers = check_import_with_http_info(task_id, opts)
data
end
# Check import status
# Check the status of requested import.
# @param task_id [String] Import by URL task ID
# @param [Hash] opts the optional parameters
# @return [Array<(FileActionResponse, Integer, Hash)>] FileActionResponse data, response status code and response headers
def check_import_with_http_info(task_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FilesApi.check_import ...'
end
# verify the required parameter 'task_id' is set
if @api_client.config.client_side_validation && task_id.nil?
fail ArgumentError, "Missing the required parameter 'task_id' when calling FilesApi.check_import"
end
# resource path
local_var_path = '/files/v3/files/import-from-url/async/tasks/{taskId}/status'.sub('{' + 'taskId' + '}', CGI.escape(task_id.to_s))
# query parameters
query_params = opts[:query_params] || {}
# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body]
# return_type
return_type = opts[:debug_return_type] || 'FileActionResponse'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"FilesApi.check_import",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: FilesApi#check_import\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# GDPR-delete file
# Delete a file in accordance with GDPR regulations.
# @param file_id [String] ID of file to GDPR delete
# @param [Hash] opts the optional parameters
# @return [nil]
def delete(file_id, opts = {})
delete_with_http_info(file_id, opts)
nil
end
# GDPR-delete file
# Delete a file in accordance with GDPR regulations.
# @param file_id [String] ID of file to GDPR delete
# @param [Hash] opts the optional parameters
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
def delete_with_http_info(file_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FilesApi.delete ...'
end
# verify the required parameter 'file_id' is set
if @api_client.config.client_side_validation && file_id.nil?
fail ArgumentError, "Missing the required parameter 'file_id' when calling FilesApi.delete"
end
pattern = Regexp.new(/\d+/)
if @api_client.config.client_side_validation && file_id !~ pattern
fail ArgumentError, "invalid value for 'file_id' when calling FilesApi.delete, must conform to the pattern #{pattern}."
end
# resource path
local_var_path = '/files/v3/files/{fileId}/gdpr-delete'.sub('{' + 'fileId' + '}', CGI.escape(file_id.to_s))
# query parameters
query_params = opts[:query_params] || {}
# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['*/*'])
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body]
# return_type
return_type = opts[:debug_return_type]
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"FilesApi.delete",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: FilesApi#delete\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Search files
# Search through files in the file manager. Does not display hidden or archived files.
# @param [Hash] opts the optional parameters
# @option opts [Array<String>] :properties A list of file properties to return.
# @option opts [String] :after Offset search results by this value. The default offset is 0 and the maximum offset of items for a given search is 10,000. Narrow your search down if you are reaching this limit.
# @option opts [String] :before
# @option opts [Integer] :limit Number of items to return. Default limit is 10, maximum limit is 100.
# @option opts [Array<String>] :sort Sort files by a given field.
# @option opts [Array<Integer>] :ids Search by a list of file IDs.
# @option opts [Integer] :id_lte
# @option opts [Integer] :id_gte
# @option opts [Time] :created_at Search files by time of creation.
# @option opts [Time] :created_at_lte Search files by less than or equal to time of creation. Can be used with `createdAtGte` to create a range.
# @option opts [Time] :created_at_gte Search files by greater than or equal to time of creation. Can be used with `createdAtLte` to create a range.
# @option opts [Time] :updated_at Search files by time of latest updated.
# @option opts [Time] :updated_at_lte Search files by less than or equal to time of latest update. Can be used with `updatedAtGte` to create a range.
# @option opts [Time] :updated_at_gte Search files by greater than or equal to time of latest update. Can be used with `updatedAtLte` to create a range.
# @option opts [String] :name Search for files containing the given name.
# @option opts [String] :path Search files by path.
# @option opts [Array<Integer>] :parent_folder_ids Search files within given `folderId`.
# @option opts [Integer] :size Search files by exact file size in bytes.
# @option opts [Integer] :size_lte Search files by less than or equal to file size. Can be used with `sizeGte` to create a range.
# @option opts [Integer] :size_gte Search files by greater than or equal to file size. Can be used with `sizeLte` to create a range.
# @option opts [Integer] :height Search files by height of image or video.
# @option opts [Integer] :height_lte Search files by less than or equal to height of image or video. Can be used with `heightGte` to create a range.
# @option opts [Integer] :height_gte Search files by greater than or equal to height of image or video. Can be used with `heightLte` to create a range.
# @option opts [Integer] :width Search files by width of image or video.
# @option opts [Integer] :width_lte Search files by less than or equal to width of image or video. Can be used with `widthGte` to create a range.
# @option opts [Integer] :width_gte Search files by greater than or equal to width of image or video. Can be used with `widthLte` to create a range.
# @option opts [String] :encoding Search files by specified encoding.
# @option opts [String] :type Filter by provided file type.
# @option opts [String] :extension Search files by given extension.
# @option opts [String] :url Search by file URL.
# @option opts [Boolean] :is_usable_in_content If `true`, shows files that have been marked to be used in new content. If `false`, shows files that should not be used in new content.
# @option opts [Boolean] :allows_anonymous_access Search files by access. If `true`, will show only public files. If `false`, will show only private files.
# @option opts [String] :file_md5 Search files by a specific md5 hash.
# @option opts [Time] :expires_at Search files by exact expires time. Time must be epoch time in milliseconds.
# @option opts [Time] :expires_at_lte Search files by less than or equal to expires time. Can be used with `expiresAtGte` to create a range.
# @option opts [Time] :expires_at_gte Search files by greater than or equal to expires time. Can be used with `expiresAtLte` to create a range.
# @return [CollectionResponseFile]
def do_search(opts = {})
data, _status_code, _headers = do_search_with_http_info(opts)
data
end
# Search files
# Search through files in the file manager. Does not display hidden or archived files.
# @param [Hash] opts the optional parameters
# @option opts [Array<String>] :properties A list of file properties to return.
# @option opts [String] :after Offset search results by this value. The default offset is 0 and the maximum offset of items for a given search is 10,000. Narrow your search down if you are reaching this limit.
# @option opts [String] :before
# @option opts [Integer] :limit Number of items to return. Default limit is 10, maximum limit is 100.
# @option opts [Array<String>] :sort Sort files by a given field.
# @option opts [Array<Integer>] :ids Search by a list of file IDs.
# @option opts [Integer] :id_lte
# @option opts [Integer] :id_gte
# @option opts [Time] :created_at Search files by time of creation.
# @option opts [Time] :created_at_lte Search files by less than or equal to time of creation. Can be used with `createdAtGte` to create a range.
# @option opts [Time] :created_at_gte Search files by greater than or equal to time of creation. Can be used with `createdAtLte` to create a range.
# @option opts [Time] :updated_at Search files by time of latest updated.
# @option opts [Time] :updated_at_lte Search files by less than or equal to time of latest update. Can be used with `updatedAtGte` to create a range.
# @option opts [Time] :updated_at_gte Search files by greater than or equal to time of latest update. Can be used with `updatedAtLte` to create a range.
# @option opts [String] :name Search for files containing the given name.
# @option opts [String] :path Search files by path.
# @option opts [Array<Integer>] :parent_folder_ids Search files within given `folderId`.
# @option opts [Integer] :size Search files by exact file size in bytes.
# @option opts [Integer] :size_lte Search files by less than or equal to file size. Can be used with `sizeGte` to create a range.
# @option opts [Integer] :size_gte Search files by greater than or equal to file size. Can be used with `sizeLte` to create a range.
# @option opts [Integer] :height Search files by height of image or video.
# @option opts [Integer] :height_lte Search files by less than or equal to height of image or video. Can be used with `heightGte` to create a range.
# @option opts [Integer] :height_gte Search files by greater than or equal to height of image or video. Can be used with `heightLte` to create a range.
# @option opts [Integer] :width Search files by width of image or video.
# @option opts [Integer] :width_lte Search files by less than or equal to width of image or video. Can be used with `widthGte` to create a range.
# @option opts [Integer] :width_gte Search files by greater than or equal to width of image or video. Can be used with `widthLte` to create a range.
# @option opts [String] :encoding Search files by specified encoding.
# @option opts [String] :type Filter by provided file type.
# @option opts [String] :extension Search files by given extension.
# @option opts [String] :url Search by file URL.
# @option opts [Boolean] :is_usable_in_content If `true`, shows files that have been marked to be used in new content. If `false`, shows files that should not be used in new content.
# @option opts [Boolean] :allows_anonymous_access Search files by access. If `true`, will show only public files. If `false`, will show only private files.
# @option opts [String] :file_md5 Search files by a specific md5 hash.
# @option opts [Time] :expires_at Search files by exact expires time. Time must be epoch time in milliseconds.
# @option opts [Time] :expires_at_lte Search files by less than or equal to expires time. Can be used with `expiresAtGte` to create a range.
# @option opts [Time] :expires_at_gte Search files by greater than or equal to expires time. Can be used with `expiresAtLte` to create a range.
# @return [Array<(CollectionResponseFile, Integer, Hash)>] CollectionResponseFile data, response status code and response headers
def do_search_with_http_info(opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FilesApi.do_search ...'
end
# resource path
local_var_path = '/files/v3/files/search'
# query parameters
query_params = opts[:query_params] || {}
query_params[:'properties'] = @api_client.build_collection_param(opts[:'properties'], :csv) if !opts[:'properties'].nil?
query_params[:'after'] = opts[:'after'] if !opts[:'after'].nil?
query_params[:'before'] = opts[:'before'] if !opts[:'before'].nil?
query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
query_params[:'sort'] = @api_client.build_collection_param(opts[:'sort'], :multi) if !opts[:'sort'].nil?
query_params[:'ids'] = @api_client.build_collection_param(opts[:'ids'], :multi) if !opts[:'ids'].nil?
query_params[:'idLte'] = opts[:'id_lte'] if !opts[:'id_lte'].nil?
query_params[:'idGte'] = opts[:'id_gte'] if !opts[:'id_gte'].nil?
query_params[:'createdAt'] = opts[:'created_at'] if !opts[:'created_at'].nil?
query_params[:'createdAtLte'] = opts[:'created_at_lte'] if !opts[:'created_at_lte'].nil?
query_params[:'createdAtGte'] = opts[:'created_at_gte'] if !opts[:'created_at_gte'].nil?
query_params[:'updatedAt'] = opts[:'updated_at'] if !opts[:'updated_at'].nil?
query_params[:'updatedAtLte'] = opts[:'updated_at_lte'] if !opts[:'updated_at_lte'].nil?
query_params[:'updatedAtGte'] = opts[:'updated_at_gte'] if !opts[:'updated_at_gte'].nil?
query_params[:'name'] = opts[:'name'] if !opts[:'name'].nil?
query_params[:'path'] = opts[:'path'] if !opts[:'path'].nil?
query_params[:'parentFolderIds'] = @api_client.build_collection_param(opts[:'parent_folder_ids'], :multi) if !opts[:'parent_folder_ids'].nil?
query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?
query_params[:'sizeLte'] = opts[:'size_lte'] if !opts[:'size_lte'].nil?
query_params[:'sizeGte'] = opts[:'size_gte'] if !opts[:'size_gte'].nil?
query_params[:'height'] = opts[:'height'] if !opts[:'height'].nil?
query_params[:'heightLte'] = opts[:'height_lte'] if !opts[:'height_lte'].nil?
query_params[:'heightGte'] = opts[:'height_gte'] if !opts[:'height_gte'].nil?
query_params[:'width'] = opts[:'width'] if !opts[:'width'].nil?
query_params[:'widthLte'] = opts[:'width_lte'] if !opts[:'width_lte'].nil?
query_params[:'widthGte'] = opts[:'width_gte'] if !opts[:'width_gte'].nil?
query_params[:'encoding'] = opts[:'encoding'] if !opts[:'encoding'].nil?
query_params[:'type'] = opts[:'type'] if !opts[:'type'].nil?
query_params[:'extension'] = opts[:'extension'] if !opts[:'extension'].nil?
query_params[:'url'] = opts[:'url'] if !opts[:'url'].nil?
query_params[:'isUsableInContent'] = opts[:'is_usable_in_content'] if !opts[:'is_usable_in_content'].nil?
query_params[:'allowsAnonymousAccess'] = opts[:'allows_anonymous_access'] if !opts[:'allows_anonymous_access'].nil?
query_params[:'fileMd5'] = opts[:'file_md5'] if !opts[:'file_md5'].nil?
query_params[:'expiresAt'] = opts[:'expires_at'] if !opts[:'expires_at'].nil?
query_params[:'expiresAtLte'] = opts[:'expires_at_lte'] if !opts[:'expires_at_lte'].nil?
query_params[:'expiresAtGte'] = opts[:'expires_at_gte'] if !opts[:'expires_at_gte'].nil?
# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body]
# return_type
return_type = opts[:debug_return_type] || 'CollectionResponseFile'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"FilesApi.do_search",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: FilesApi#do_search\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Retrieve file by ID
# Retrieve a file by its ID.
# @param file_id [String] ID of the desired file.
# @param [Hash] opts the optional parameters
# @option opts [Array<String>] :properties null
# @return [File]
def get_by_id(file_id, opts = {})
data, _status_code, _headers = get_by_id_with_http_info(file_id, opts)
data
end
# Retrieve file by ID
# Retrieve a file by its ID.
# @param file_id [String] ID of the desired file.
# @param [Hash] opts the optional parameters
# @option opts [Array<String>] :properties null
# @return [Array<(File, Integer, Hash)>] File data, response status code and response headers
def get_by_id_with_http_info(file_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FilesApi.get_by_id ...'
end
# verify the required parameter 'file_id' is set
if @api_client.config.client_side_validation && file_id.nil?
fail ArgumentError, "Missing the required parameter 'file_id' when calling FilesApi.get_by_id"
end
pattern = Regexp.new(/\d+/)
if @api_client.config.client_side_validation && file_id !~ pattern
fail ArgumentError, "invalid value for 'file_id' when calling FilesApi.get_by_id, must conform to the pattern #{pattern}."
end
# resource path
local_var_path = '/files/v3/files/{fileId}'.sub('{' + 'fileId' + '}', CGI.escape(file_id.to_s))
# query parameters
query_params = opts[:query_params] || {}
query_params[:'properties'] = @api_client.build_collection_param(opts[:'properties'], :csv) if !opts[:'properties'].nil?
# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body]
# return_type
return_type = opts[:debug_return_type] || 'File'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"FilesApi.get_by_id",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: FilesApi#get_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Retrieve file by path
# Retrieve a file by its path.
# @param path [String] The path of the file.
# @param [Hash] opts the optional parameters
# @option opts [Array<String>] :properties Properties to return in the response.
# @return [FileStat]
def get_metadata(path, opts = {})
data, _status_code, _headers = get_metadata_with_http_info(path, opts)
data
end
# Retrieve file by path
# Retrieve a file by its path.
# @param path [String] The path of the file.
# @param [Hash] opts the optional parameters
# @option opts [Array<String>] :properties Properties to return in the response.
# @return [Array<(FileStat, Integer, Hash)>] FileStat data, response status code and response headers
def get_metadata_with_http_info(path, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FilesApi.get_metadata ...'
end
# verify the required parameter 'path' is set
if @api_client.config.client_side_validation && path.nil?
fail ArgumentError, "Missing the required parameter 'path' when calling FilesApi.get_metadata"
end
pattern = Regexp.new(/.+/)
if @api_client.config.client_side_validation && path !~ pattern
fail ArgumentError, "invalid value for 'path' when calling FilesApi.get_metadata, must conform to the pattern #{pattern}."
end
# resource path
local_var_path = '/files/v3/files/stat/{path}'.sub('{' + 'path' + '}', CGI.escape(path.to_s))
# query parameters
query_params = opts[:query_params] || {}
query_params[:'properties'] = @api_client.build_collection_param(opts[:'properties'], :csv) if !opts[:'properties'].nil?
# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body]
# return_type
return_type = opts[:debug_return_type] || 'FileStat'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"FilesApi.get_metadata",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: FilesApi#get_metadata\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Get signed URL to access private file
# Generates signed URL that allows temporary access to a private file.
# @param file_id [String] ID of file.
# @param [Hash] opts the optional parameters
# @option opts [String] :size For image files. This will resize the image to the desired size before sharing. Does not affect the original file, just the file served by this signed URL.
# @option opts [Integer] :expiration_seconds How long in seconds the link will provide access to the file.
# @option opts [Boolean] :upscale If size is provided, this will upscale the image to fit the size dimensions.
# @return [SignedUrl]
def get_signed_url(file_id, opts = {})
data, _status_code, _headers = get_signed_url_with_http_info(file_id, opts)
data
end
# Get signed URL to access private file
# Generates signed URL that allows temporary access to a private file.
# @param file_id [String] ID of file.
# @param [Hash] opts the optional parameters
# @option opts [String] :size For image files. This will resize the image to the desired size before sharing. Does not affect the original file, just the file served by this signed URL.
# @option opts [Integer] :expiration_seconds How long in seconds the link will provide access to the file.
# @option opts [Boolean] :upscale If size is provided, this will upscale the image to fit the size dimensions.
# @return [Array<(SignedUrl, Integer, Hash)>] SignedUrl data, response status code and response headers
def get_signed_url_with_http_info(file_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FilesApi.get_signed_url ...'
end
# verify the required parameter 'file_id' is set
if @api_client.config.client_side_validation && file_id.nil?
fail ArgumentError, "Missing the required parameter 'file_id' when calling FilesApi.get_signed_url"
end
pattern = Regexp.new(/\d+/)
if @api_client.config.client_side_validation && file_id !~ pattern
fail ArgumentError, "invalid value for 'file_id' when calling FilesApi.get_signed_url, must conform to the pattern #{pattern}."
end
allowable_values = ["thumb", "icon", "medium", "preview"]
if @api_client.config.client_side_validation && opts[:'size'] && !allowable_values.include?(opts[:'size'])
fail ArgumentError, "invalid value for \"size\", must be one of #{allowable_values}"
end
# resource path
local_var_path = '/files/v3/files/{fileId}/signed-url'.sub('{' + 'fileId' + '}', CGI.escape(file_id.to_s))
# query parameters
query_params = opts[:query_params] || {}
query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?
query_params[:'expirationSeconds'] = opts[:'expiration_seconds'] if !opts[:'expiration_seconds'].nil?
query_params[:'upscale'] = opts[:'upscale'] if !opts[:'upscale'].nil?
# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body]
# return_type
return_type = opts[:debug_return_type] || 'SignedUrl'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"FilesApi.get_signed_url",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: FilesApi#get_signed_url\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Import file from URL
# Asynchronously imports the file at the given URL into the file manager.
# @param import_from_url_input [ImportFromUrlInput]
# @param [Hash] opts the optional parameters
# @return [ImportFromUrlTaskLocator]
def import_from_url(import_from_url_input, opts = {})
data, _status_code, _headers = import_from_url_with_http_info(import_from_url_input, opts)
data
end
# Import file from URL
# Asynchronously imports the file at the given URL into the file manager.
# @param import_from_url_input [ImportFromUrlInput]
# @param [Hash] opts the optional parameters
# @return [Array<(ImportFromUrlTaskLocator, Integer, Hash)>] ImportFromUrlTaskLocator data, response status code and response headers
def import_from_url_with_http_info(import_from_url_input, opts = {})
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | true |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/crm/schemas/api_error.rb | lib/hubspot/codegen/crm/schemas/api_error.rb | =begin
#Schemas
#The CRM uses schemas to define how custom objects should store and represent information in the HubSpot CRM. Schemas define details about an object's type, properties, and associations. The schema can be uniquely identified by its **object type ID**.
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
module Hubspot
module Crm
module Schemas
class ApiError < ::StandardError
attr_reader :code, :response_headers, :response_body
# Usage examples:
# ApiError.new
# ApiError.new("message")
# ApiError.new(:code => 500, :response_headers => {}, :response_body => "")
# ApiError.new(:code => 404, :message => "Not Found")
def initialize(arg = nil)
if arg.is_a? Hash
if arg.key?(:message) || arg.key?('message')
super(arg[:message] || arg['message'])
else
super arg
end
arg.each do |k, v|
instance_variable_set "@#{k}", v
end
else
super arg
end
end
# Override to_s to display a friendly error message
def to_s
message
end
def message
if @message.nil?
msg = "Error message: the server returns an error"
else
msg = @message
end
msg += "\nHTTP status code: #{code}" if code
msg += "\nResponse headers: #{response_headers}" if response_headers
msg += "\nResponse body: #{response_body}" if response_body
msg
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/crm/schemas/configuration.rb | lib/hubspot/codegen/crm/schemas/configuration.rb | =begin
#Schemas
#The CRM uses schemas to define how custom objects should store and represent information in the HubSpot CRM. Schemas define details about an object's type, properties, and associations. The schema can be uniquely identified by its **object type ID**.
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
module Hubspot
module Crm
module Schemas
class Configuration
# Defines url scheme
attr_accessor :scheme
# Defines url host
attr_accessor :host
# Defines url base path
attr_accessor :base_path
# Define server configuration index
attr_accessor :server_index
# Define server operation configuration index
attr_accessor :server_operation_index
# Default server variables
attr_accessor :server_variables
# Default server operation variables
attr_accessor :server_operation_variables
# Defines API keys used with API Key authentications.
#
# @return [Hash] key: parameter name, value: parameter value (API key)
#
# @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
# config.api_key['api_key'] = 'xxx'
attr_accessor :api_key
# Defines API key prefixes used with API Key authentications.
#
# @return [Hash] key: parameter name, value: API key prefix
#
# @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
# config.api_key_prefix['api_key'] = 'Token'
attr_accessor :api_key_prefix
# Defines the username used with HTTP basic authentication.
#
# @return [String]
attr_accessor :username
# Defines the password used with HTTP basic authentication.
#
# @return [String]
attr_accessor :password
# Defines the access token (Bearer) used with OAuth2.
attr_accessor :access_token
# Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
# details will be logged with `logger.debug` (see the `logger` attribute).
# Default to false.
#
# @return [true, false]
attr_accessor :debugging
# Defines the logger used for debugging.
# Default to `Rails.logger` (when in Rails) or logging to STDOUT.
#
# @return [#debug]
attr_accessor :logger
# Defines the temporary folder to store downloaded files
# (for API endpoints that have file response).
# Default to use `Tempfile`.
#
# @return [String]
attr_accessor :temp_folder_path
# The time limit for HTTP request in seconds.
# Default to 0 (never times out).
attr_accessor :timeout
# Set this to false to skip client side validation in the operation.
# Default to true.
# @return [true, false]
attr_accessor :client_side_validation
### TLS/SSL setting
# Set this to false to skip verifying SSL certificate when calling API from https server.
# Default to true.
#
# @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
#
# @return [true, false]
attr_accessor :verify_ssl
### TLS/SSL setting
# Set this to false to skip verifying SSL host name
# Default to true.
#
# @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
#
# @return [true, false]
attr_accessor :verify_ssl_host
### TLS/SSL setting
# Set this to customize the certificate file to verify the peer.
#
# @return [String] the path to the certificate file
#
# @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code:
# https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
attr_accessor :ssl_ca_cert
### TLS/SSL setting
# Client certificate file (for client certificate)
attr_accessor :cert_file
### TLS/SSL setting
# Client private key file (for client certificate)
attr_accessor :key_file
# Set this to customize parameters encoding of array parameter with multi collectionFormat.
# Default to nil.
#
# @see The params_encoding option of Ethon. Related source code:
# https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
attr_accessor :params_encoding
attr_accessor :inject_format
attr_accessor :force_ending_format
attr_accessor :error_handler
def initialize
@scheme = 'https'
@host = 'api.hubapi.com'
@base_path = ''
@server_index = 0
@server_operation_index = {}
@server_variables = {}
@server_operation_variables = {}
@api_key = {}
@api_key_prefix = {}
@client_side_validation = true
@verify_ssl = true
@verify_ssl_host = true
@cert_file = nil
@key_file = nil
@timeout = 0
@params_encoding = nil
@debugging = false
@inject_format = false
@force_ending_format = false
@logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
# error_handler params: { 'status_code': { max_retries: ..., seconds_delay: ... }, ... }
@error_handler = {}
yield(self) if block_given?
end
# The default Configuration object.
def self.default
@@default ||= Configuration.new
end
def configure
yield(self) if block_given?
end
def scheme=(scheme)
# remove :// from scheme
@scheme = scheme.sub(/:\/\//, '')
end
def host=(host)
# remove http(s):// and anything after a slash
@host = host.sub(/https?:\/\//, '').split('/').first
end
def base_path=(base_path)
# Add leading and trailing slashes to base_path
@base_path = "/#{base_path}".gsub(/\/+/, '/')
@base_path = '' if @base_path == '/'
end
# Returns base URL for specified operation based on server settings
def base_url(operation = nil)
index = server_operation_index.fetch(operation, server_index)
return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if index == nil
server_url(index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
end
# Gets API key (with prefix if set).
# @param [String] param_name the parameter name of API key auth
def api_key_with_prefix(param_name, param_alias = nil)
key = @api_key[param_name]
key = @api_key.fetch(param_alias, key) unless param_alias.nil?
if @api_key_prefix[param_name]
"#{@api_key_prefix[param_name]} #{key}"
else
key
end
end
# Gets Basic Auth token string
def basic_auth_token
'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
end
# Returns Auth Settings hash for api client.
def auth_settings
{
'oauth2' =>
{
type: 'oauth2',
in: 'header',
key: 'Authorization',
value: "Bearer #{access_token}"
},
}
end
# Returns an array of Server setting
def server_settings
[
{
url: "https://api.hubapi.com",
description: "No description provided",
}
]
end
def operation_server_settings
{
}
end
# Returns URL based on server settings
#
# @param index array index of the server settings
# @param variables hash of variable and the corresponding value
def server_url(index, variables = {}, servers = nil)
servers = server_settings if servers == nil
# check array index out of bound
if (index < 0 || index >= servers.size)
fail ArgumentError, "Invalid index #{index} when selecting the server. Must be less than #{servers.size}"
end
server = servers[index]
url = server[:url]
return url unless server.key? :variables
# go through variable and assign a value
server[:variables].each do |name, variable|
if variables.key?(name)
if (!server[:variables][name].key?(:enum_values) || server[:variables][name][:enum_values].include?(variables[name]))
url.gsub! "{" + name.to_s + "}", variables[name]
else
fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."
end
else
# use default value
url.gsub! "{" + name.to_s + "}", server[:variables][name][:default_value]
end
end
url
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/crm/schemas/api_client.rb | lib/hubspot/codegen/crm/schemas/api_client.rb | =begin
#Schemas
#The CRM uses schemas to define how custom objects should store and represent information in the HubSpot CRM. Schemas define details about an object's type, properties, and associations. The schema can be uniquely identified by its **object type ID**.
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'json'
require 'logger'
require 'tempfile'
require 'time'
require 'typhoeus'
module Hubspot
module Crm
module Schemas
class ApiClient
# The Configuration object holding settings to be used in the API client.
attr_accessor :config
# Defines the headers to be used in HTTP requests of all API calls by default.
#
# @return [Hash]
attr_accessor :default_headers
# Initializes the ApiClient
# @option config [Configuration] Configuration for initializing the object, default to Configuration.default
def initialize(config = Configuration.default)
@config = config
@user_agent = "hubspot-api-client-ruby; #{VERSION}"
@default_headers = {
'Content-Type' => 'application/json',
'User-Agent' => @user_agent
}
end
def self.default
@@default ||= ApiClient.new
end
# Call an API with given options.
#
# @return [Array<(Object, Integer, Hash)>] an array of 3 elements:
# the data deserialized from response body (could be nil), response status code and response headers.
def call_api(http_method, path, opts = {})
request = build_request(http_method, path, opts)
response = request.run
if @config.debugging
@config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
end
if !response.success? && config.error_handler.any?
config.error_handler.each do |statuses, opts|
statuses = statuses.is_a?(Integer) ? [statuses] : statuses
retries = opts[:max_retries] || 5
while retries > 0 && statuses.include?(response.code)
sleep opts[:seconds_delay] if opts[:seconds_delay]
response = request.run
opts[:retry_block].call if opts[:retry_block]
retries -= 1
end
end
end
unless response.success?
if response.timed_out?
fail ApiError.new('Connection timed out')
elsif response.code == 0
# Errors from libcurl will be made visible here
fail ApiError.new(:code => 0,
:message => response.return_message)
else
fail ApiError.new(:code => response.code,
:response_headers => response.headers,
:response_body => response.body),
response.status_message
end
end
if opts[:return_type]
data = deserialize(response, opts[:return_type])
else
data = nil
end
return data, response.code, response.headers
end
# Builds the HTTP request
#
# @param [String] http_method HTTP method/verb (e.g. POST)
# @param [String] path URL path (e.g. /account/new)
# @option opts [Hash] :header_params Header parameters
# @option opts [Hash] :query_params Query parameters
# @option opts [Hash] :form_params Query parameters
# @option opts [Object] :body HTTP body (JSON/XML)
# @return [Typhoeus::Request] A Typhoeus Request
def build_request(http_method, path, opts = {})
url = build_request_url(path, opts)
http_method = http_method.to_sym.downcase
header_params = @default_headers.merge(opts[:header_params] || {})
query_params = opts[:query_params] || {}
form_params = opts[:form_params] || {}
follow_location = opts[:follow_location] || true
update_params_for_auth! header_params, query_params, opts[:auth_names]
# set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)
_verify_ssl_host = @config.verify_ssl_host ? 2 : 0
req_opts = {
:method => http_method,
:headers => header_params,
:params => query_params,
:params_encoding => @config.params_encoding,
:timeout => @config.timeout,
:ssl_verifypeer => @config.verify_ssl,
:ssl_verifyhost => _verify_ssl_host,
:sslcert => @config.cert_file,
:sslkey => @config.key_file,
:verbose => @config.debugging,
:followlocation => follow_location
}
# set custom cert, if provided
req_opts[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert
if [:post, :patch, :put, :delete].include?(http_method)
req_body = build_request_body(header_params, form_params, opts[:body])
req_opts.update :body => req_body
if @config.debugging
@config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n"
end
end
request = Typhoeus::Request.new(url, req_opts)
download_file(request) if opts[:return_type] == 'File'
request
end
# Builds the HTTP request body
#
# @param [Hash] header_params Header parameters
# @param [Hash] form_params Query parameters
# @param [Object] body HTTP body (JSON/XML)
# @return [String] HTTP body data in the form of string
def build_request_body(header_params, form_params, body)
# http form
if header_params['Content-Type'] == 'application/x-www-form-urlencoded' ||
header_params['Content-Type'] == 'multipart/form-data'
data = {}
form_params.each do |key, value|
case value
when ::File, ::Array, nil
# let typhoeus handle File, Array and nil parameters
data[key] = value
else
data[key] = value.to_s
end
end
elsif body
data = body.is_a?(String) ? body : body.to_json
else
data = nil
end
data
end
# Save response body into a file in (the defined) temporary folder, using the filename
# from the "Content-Disposition" header if provided, otherwise a random filename.
# The response body is written to the file in chunks in order to handle files which
# size is larger than maximum Ruby String or even larger than the maximum memory a Ruby
# process can use.
#
# @see Configuration#temp_folder_path
def download_file(request)
tempfile = nil
encoding = nil
request.on_headers do |response|
content_disposition = response.headers['Content-Disposition']
if content_disposition && content_disposition =~ /filename=/i
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
prefix = sanitize_filename(filename)
else
prefix = 'download-'
end
prefix = prefix + '-' unless prefix.end_with?('-')
encoding = response.body.encoding
tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
@tempfile = tempfile
end
request.on_body do |chunk|
chunk.force_encoding(encoding)
tempfile.write(chunk)
end
request.on_complete do |response|
if tempfile
tempfile.close
@config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
"will be deleted automatically with GC. It's also recommended to delete the temp file "\
"explicitly with `tempfile.delete`"
end
end
end
# Check if the given MIME is a JSON MIME.
# JSON MIME examples:
# application/json
# application/json; charset=UTF8
# APPLICATION/JSON
# */*
# @param [String] mime MIME
# @return [Boolean] True if the MIME is application/json
def json_mime?(mime)
(mime == '*/*') || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
end
# Deserialize the response to the given return type.
#
# @param [Response] response HTTP response
# @param [String] return_type some examples: "User", "Array<User>", "Hash<String, Integer>"
def deserialize(response, return_type)
body = response.body
# handle file downloading - return the File instance processed in request callbacks
# note that response body is empty when the file is written in chunks in request on_body callback
return @tempfile if return_type == 'File'
return nil if body.nil? || body.empty?
# return response body directly for String return type
return body if return_type == 'String'
# ensuring a default content type
content_type = response.headers['Content-Type'] || 'application/json'
fail "Content-Type is not supported: #{content_type}" unless json_mime?(content_type)
begin
data = JSON.parse("[#{body}]", :symbolize_names => true)[0]
rescue JSON::ParserError => e
if %w(String Date Time).include?(return_type)
data = body
else
raise e
end
end
convert_to_type data, return_type
end
# Convert data to the given return type.
# @param [Object] data Data to be converted
# @param [String] return_type Return type
# @return [Mixed] Data in a particular type
def convert_to_type(data, return_type)
return nil if data.nil?
case return_type
when 'String'
data.to_s
when 'Integer'
data.to_i
when 'Float'
data.to_f
when 'Boolean'
data == true
when 'Time'
# parse date time (expecting ISO 8601 format)
Time.parse data
when 'Date'
# parse date time (expecting ISO 8601 format)
Date.parse data
when 'Object'
# generic object (usually a Hash), return directly
data
when /\AArray<(.+)>\z/
# e.g. Array<Pet>
sub_type = $1
data.map { |item| convert_to_type(item, sub_type) }
when /\AHash\<String, (.+)\>\z/
# e.g. Hash<String, Integer>
sub_type = $1
{}.tap do |hash|
data.each { |k, v| hash[k] = convert_to_type(v, sub_type) }
end
else
# models (e.g. Pet) or oneOf
klass = Hubspot::Crm::Schemas.const_get(return_type)
klass.respond_to?(:openapi_one_of) ? klass.build(data) : klass.build_from_hash(data)
end
end
# Sanitize filename by removing path.
# e.g. ../../sun.gif becomes sun.gif
#
# @param [String] filename the filename to be sanitized
# @return [String] the sanitized filename
def sanitize_filename(filename)
filename.gsub(/.*[\/\\]/, '')
end
def build_request_url(path, opts = {})
# Add leading and trailing slashes to path
path = "/#{path}".gsub(/\/+/, '/')
@config.base_url(opts[:operation]) + path
end
# Update header and query params based on authentication settings.
#
# @param [Hash] header_params Header parameters
# @param [Hash] query_params Query parameters
# @param [String] auth_names Authentication scheme name
def update_params_for_auth!(header_params, query_params, auth_names)
Array(auth_names).each do |auth_name|
auth_setting = @config.auth_settings[auth_name]
next unless auth_setting
case auth_setting[:in]
when 'header' then header_params[auth_setting[:key]] = auth_setting[:value]
when 'query' then query_params[auth_setting[:key]] = auth_setting[:value]
else fail ArgumentError, 'Authentication token must be in `query` or `header`'
end
end
end
# Sets user agent in HTTP header
#
# @param [String] user_agent User agent (e.g. openapi-generator/ruby/1.0.0)
def user_agent=(user_agent)
@user_agent = user_agent
@default_headers['User-Agent'] = @user_agent
end
# Return Accept header based on an array of accepts provided.
# @param [Array] accepts array for Accept
# @return [String] the Accept header (e.g. application/json)
def select_header_accept(accepts)
return nil if accepts.nil? || accepts.empty?
# use JSON when present, otherwise use all of the provided
json_accept = accepts.find { |s| json_mime?(s) }
json_accept || accepts.join(',')
end
# Return Content-Type header based on an array of content types provided.
# @param [Array] content_types array for Content-Type
# @return [String] the Content-Type header (e.g. application/json)
def select_header_content_type(content_types)
# return nil by default
return if content_types.nil? || content_types.empty?
# use JSON when present, otherwise use the first one
json_content_type = content_types.find { |s| json_mime?(s) }
json_content_type || content_types.first
end
# Convert object (array, hash, object, etc) to JSON string.
# @param [Object] model object to be converted into JSON string
# @return [String] JSON string representation of the object
def object_to_http_body(model)
return model if model.nil? || model.is_a?(String)
local_body = nil
if model.is_a?(Array)
local_body = model.map { |m| object_to_hash(m) }
else
local_body = object_to_hash(model)
end
local_body.to_json
end
# Convert object(non-array) to hash.
# @param [Object] obj object to be converted into JSON string
# @return [String] JSON string representation of the object
def object_to_hash(obj)
if obj.respond_to?(:to_hash)
obj.to_hash
else
obj
end
end
# Build parameter value according to the given collection format.
# @param [String] collection_format one of :csv, :ssv, :tsv, :pipes and :multi
def build_collection_param(param, collection_format)
case collection_format
when :csv
param.join(',')
when :ssv
param.join(' ')
when :tsv
param.join("\t")
when :pipes
param.join('|')
when :multi
# return the array directly as typhoeus will handle it as expected
param
else
fail "unknown collection format: #{collection_format.inspect}"
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
HubSpot/hubspot-api-ruby | https://github.com/HubSpot/hubspot-api-ruby/blob/75a9afa65e9789fbe6ff711066d798ca0c10f432/lib/hubspot/codegen/crm/schemas/models/option_input.rb | lib/hubspot/codegen/crm/schemas/models/option_input.rb | =begin
#Schemas
#The CRM uses schemas to define how custom objects should store and represent information in the HubSpot CRM. Schemas define details about an object's type, properties, and associations. The schema can be uniquely identified by its **object type ID**.
The version of the OpenAPI document: v3
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'date'
require 'time'
module Hubspot
module Crm
module Schemas
class OptionInput
# Hidden options won't be shown in HubSpot.
attr_accessor :hidden
# Options are shown in order starting with the lowest positive integer value. Values of -1 will cause the option to be displayed after any positive values.
attr_accessor :display_order
# A description of the option.
attr_accessor :description
# A human-readable option label that will be shown in HubSpot.
attr_accessor :label
# The internal value of the option, which must be used when setting the property value through the API.
attr_accessor :value
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'hidden' => :'hidden',
:'display_order' => :'displayOrder',
:'description' => :'description',
:'label' => :'label',
:'value' => :'value'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
def self.openapi_types
{
:'hidden' => :'Boolean',
:'display_order' => :'Integer',
:'description' => :'String',
:'label' => :'String',
:'value' => :'String'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Crm::Schemas::OptionInput` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Crm::Schemas::OptionInput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'hidden')
self.hidden = attributes[:'hidden']
end
if attributes.key?(:'display_order')
self.display_order = attributes[:'display_order']
end
if attributes.key?(:'description')
self.description = attributes[:'description']
end
if attributes.key?(:'label')
self.label = attributes[:'label']
end
if attributes.key?(:'value')
self.value = attributes[:'value']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @hidden.nil?
invalid_properties.push('invalid value for "hidden", hidden cannot be nil.')
end
if @display_order.nil?
invalid_properties.push('invalid value for "display_order", display_order cannot be nil.')
end
if @label.nil?
invalid_properties.push('invalid value for "label", label cannot be nil.')
end
if @value.nil?
invalid_properties.push('invalid value for "value", value cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @hidden.nil?
return false if @display_order.nil?
return false if @label.nil?
return false if @value.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
hidden == o.hidden &&
display_order == o.display_order &&
description == o.description &&
label == o.label &&
value == o.value
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[hidden, display_order, description, label, value].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
self.class.openapi_types.each_pair do |key, type|
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Hubspot::Crm::Schemas.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
end
end
| ruby | Apache-2.0 | 75a9afa65e9789fbe6ff711066d798ca0c10f432 | 2026-01-04T17:55:03.682567Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.