Class: InfaktApiClient::User

Inherits:
Object
  • Object
show all
Defined in:
lib/infakt_api_client/user.rb

Overview

Represents a user in the Infakt API system, containing account information, company details, subscription status, and various settings. This class serves as a wrapper for user-related data returned by the Infakt API.

Defined Under Namespace

Classes: AccountData, CompanyData, Subscription

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ User

Returns a new instance of User.



78
79
80
81
82
83
84
85
86
# File 'lib/infakt_api_client/user.rb', line 78

def initialize(attributes)
  @account_data = AccountData.new(attributes["account_data"])
  @company_data = CompanyData.new(attributes["company_data"])
  @current_subscription = Subscription.new(attributes["current_subscription"])
  @accounting_settings = attributes["accounting_settings"]
  @accounting_office_service = attributes["accounting_office_service"]
  @foundation_process = attributes["foundation_process"]
  @extensions = attributes["extentions"]
end

Instance Attribute Details

#account_dataObject (readonly)

Returns the value of attribute account_data.



8
9
10
# File 'lib/infakt_api_client/user.rb', line 8

def 
  @account_data
end

#accounting_office_serviceObject (readonly)

Returns the value of attribute accounting_office_service.



8
9
10
# File 'lib/infakt_api_client/user.rb', line 8

def accounting_office_service
  @accounting_office_service
end

#accounting_settingsObject (readonly)

Returns the value of attribute accounting_settings.



8
9
10
# File 'lib/infakt_api_client/user.rb', line 8

def accounting_settings
  @accounting_settings
end

#company_dataObject (readonly)

Returns the value of attribute company_data.



8
9
10
# File 'lib/infakt_api_client/user.rb', line 8

def company_data
  @company_data
end

#current_subscriptionObject (readonly)

Returns the value of attribute current_subscription.



8
9
10
# File 'lib/infakt_api_client/user.rb', line 8

def current_subscription
  @current_subscription
end

#extensionsObject (readonly)

Returns the value of attribute extensions.



8
9
10
# File 'lib/infakt_api_client/user.rb', line 8

def extensions
  @extensions
end

#foundation_processObject (readonly)

Returns the value of attribute foundation_process.



8
9
10
# File 'lib/infakt_api_client/user.rb', line 8

def foundation_process
  @foundation_process
end

Instance Method Details

#days_to_subscription_endObject



96
97
98
# File 'lib/infakt_api_client/user.rb', line 96

def days_to_subscription_end
  current_subscription.days_until_expiration
end

#full_nameObject



88
89
90
# File 'lib/infakt_api_client/user.rb', line 88

def full_name
  "#{company_data.first_name} #{company_data.last_name}".strip
end

#ksef_active?Boolean

Returns:

  • (Boolean)


100
101
102
# File 'lib/infakt_api_client/user.rb', line 100

def ksef_active?
  extensions.dig("ksef", "active")
end

#subscription_active?Boolean

Returns:

  • (Boolean)


92
93
94
# File 'lib/infakt_api_client/user.rb', line 92

def subscription_active?
  Date.parse(current_subscription.expired_on) > Date.today
end