Class: LockstepSdk::LockstepApi
- Inherits:
-
Object
- Object
- LockstepSdk::LockstepApi
- Defined in:
- lib/lockstep_sdk/lockstep_api.rb
Instance Attribute Summary collapse
-
#activities ⇒ ActivitiesClient
Client object for Activities endpoints.
-
#api_keys ⇒ ApiKeysClient
Client object for ApiKeys endpoints.
-
#app_enrollments ⇒ AppEnrollmentsClient
Client object for AppEnrollments endpoints.
-
#applications ⇒ ApplicationsClient
Client object for Applications endpoints.
-
#attachments ⇒ AttachmentsClient
Client object for Attachments endpoints.
-
#code_definitions ⇒ CodeDefinitionsClient
Client object for CodeDefinitions endpoints.
-
#companies ⇒ CompaniesClient
Client object for Companies endpoints.
-
#contacts ⇒ ContactsClient
Client object for Contacts endpoints.
-
#credit_memo_applied ⇒ CreditMemoAppliedClient
Client object for CreditMemoApplied endpoints.
-
#currencies ⇒ CurrenciesClient
Client object for Currencies endpoints.
-
#custom_field_definitions ⇒ CustomFieldDefinitionsClient
Client object for CustomFieldDefinitions endpoints.
-
#custom_field_values ⇒ CustomFieldValuesClient
Client object for CustomFieldValues endpoints.
-
#definitions ⇒ DefinitionsClient
Client object for Definitions endpoints.
-
#emails ⇒ EmailsClient
Client object for Emails endpoints.
-
#env ⇒ String
The name or URL of the environment.
-
#financial_account ⇒ FinancialAccountClient
Client object for FinancialAccount endpoints.
-
#financial_account_balance_history ⇒ FinancialAccountBalanceHistoryClient
Client object for FinancialAccountBalanceHistory endpoints.
-
#financial_year_settings ⇒ FinancialYearSettingsClient
Client object for FinancialYearSettings endpoints.
-
#invoice_history ⇒ InvoiceHistoryClient
Client object for InvoiceHistory endpoints.
-
#invoices ⇒ InvoicesClient
Client object for Invoices endpoints.
-
#leads ⇒ LeadsClient
Client object for Leads endpoints.
-
#notes ⇒ NotesClient
Client object for Notes endpoints.
-
#payment_applications ⇒ PaymentApplicationsClient
Client object for PaymentApplications endpoints.
-
#payments ⇒ PaymentsClient
Client object for Payments endpoints.
-
#provisioning ⇒ ProvisioningClient
Client object for Provisioning endpoints.
-
#reports ⇒ ReportsClient
Client object for Reports endpoints.
-
#status ⇒ StatusClient
Client object for Status endpoints.
-
#sync ⇒ SyncClient
Client object for Sync endpoints.
-
#user_accounts ⇒ UserAccountsClient
Client object for UserAccounts endpoints.
-
#user_roles ⇒ UserRolesClient
Client object for UserRoles endpoints.
-
#version ⇒ String
The version number of this Lockstep API client.
-
#webhooks ⇒ WebhooksClient
Client object for Webhooks endpoints.
Instance Method Summary collapse
-
#initialize(env) ⇒ LockstepApi
constructor
Construct a new Lockstep API client targeting the specified server.
-
#request(method, path, body, params) ⇒ Object
Send a request to the API and return the results.
-
#with_api_key(api_key) ⇒ Object
Configure this API client to use API key authentication.
-
#with_app_name(app_name) ⇒ Object
Configure this API to use an application name.
-
#with_bearer_token(bearer_token) ⇒ Object
Configure this API client to use JWT Bearer Token authentication.
Constructor Details
#initialize(env) ⇒ LockstepApi
Construct a new Lockstep API client targeting the specified server.
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 161 def initialize(env) @version = "2022.9.6.0" @env = case env when "sbx" "https://api.sbx.lockstep.io/" when "prd" "https://api.lockstep.io/" else env end # Construct all the clients @activities = ActivitiesClient.new(self) @api_keys = ApiKeysClient.new(self) @app_enrollments = AppEnrollmentsClient.new(self) @applications = ApplicationsClient.new(self) @attachments = AttachmentsClient.new(self) @code_definitions = CodeDefinitionsClient.new(self) @companies = CompaniesClient.new(self) @contacts = ContactsClient.new(self) @credit_memo_applied = CreditMemoAppliedClient.new(self) @currencies = CurrenciesClient.new(self) @custom_field_definitions = CustomFieldDefinitionsClient.new(self) @custom_field_values = CustomFieldValuesClient.new(self) @definitions = DefinitionsClient.new(self) @emails = EmailsClient.new(self) @financial_account = FinancialAccountClient.new(self) @financial_account_balance_history = FinancialAccountBalanceHistoryClient.new(self) @financial_year_settings = FinancialYearSettingsClient.new(self) @invoice_history = InvoiceHistoryClient.new(self) @invoices = InvoicesClient.new(self) @leads = LeadsClient.new(self) @notes = NotesClient.new(self) @payment_applications = PaymentApplicationsClient.new(self) @payments = PaymentsClient.new(self) @provisioning = ProvisioningClient.new(self) @reports = ReportsClient.new(self) @status = StatusClient.new(self) @sync = SyncClient.new(self) @user_accounts = UserAccountsClient.new(self) @user_roles = UserRolesClient.new(self) @webhooks = WebhooksClient.new(self) end |
Instance Attribute Details
#activities ⇒ ActivitiesClient
Returns Client object for Activities endpoints.
38 39 40 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 38 def activities @activities end |
#api_keys ⇒ ApiKeysClient
Returns Client object for ApiKeys endpoints.
42 43 44 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 42 def api_keys @api_keys end |
#app_enrollments ⇒ AppEnrollmentsClient
Returns Client object for AppEnrollments endpoints.
46 47 48 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 46 def app_enrollments @app_enrollments end |
#applications ⇒ ApplicationsClient
Returns Client object for Applications endpoints.
50 51 52 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 50 def applications @applications end |
#attachments ⇒ AttachmentsClient
Returns Client object for Attachments endpoints.
54 55 56 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 54 def @attachments end |
#code_definitions ⇒ CodeDefinitionsClient
Returns Client object for CodeDefinitions endpoints.
58 59 60 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 58 def code_definitions @code_definitions end |
#companies ⇒ CompaniesClient
Returns Client object for Companies endpoints.
62 63 64 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 62 def companies @companies end |
#contacts ⇒ ContactsClient
Returns Client object for Contacts endpoints.
66 67 68 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 66 def contacts @contacts end |
#credit_memo_applied ⇒ CreditMemoAppliedClient
Returns Client object for CreditMemoApplied endpoints.
70 71 72 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 70 def credit_memo_applied @credit_memo_applied end |
#currencies ⇒ CurrenciesClient
Returns Client object for Currencies endpoints.
74 75 76 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 74 def currencies @currencies end |
#custom_field_definitions ⇒ CustomFieldDefinitionsClient
Returns Client object for CustomFieldDefinitions endpoints.
78 79 80 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 78 def custom_field_definitions @custom_field_definitions end |
#custom_field_values ⇒ CustomFieldValuesClient
Returns Client object for CustomFieldValues endpoints.
82 83 84 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 82 def custom_field_values @custom_field_values end |
#definitions ⇒ DefinitionsClient
Returns Client object for Definitions endpoints.
86 87 88 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 86 def definitions @definitions end |
#emails ⇒ EmailsClient
Returns Client object for Emails endpoints.
90 91 92 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 90 def emails @emails end |
#env ⇒ String
Returns The name or URL of the environment.
34 35 36 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 34 def env @env end |
#financial_account ⇒ FinancialAccountClient
Returns Client object for FinancialAccount endpoints.
94 95 96 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 94 def financial_account @financial_account end |
#financial_account_balance_history ⇒ FinancialAccountBalanceHistoryClient
Returns Client object for FinancialAccountBalanceHistory endpoints.
98 99 100 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 98 def financial_account_balance_history @financial_account_balance_history end |
#financial_year_settings ⇒ FinancialYearSettingsClient
Returns Client object for FinancialYearSettings endpoints.
102 103 104 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 102 def financial_year_settings @financial_year_settings end |
#invoice_history ⇒ InvoiceHistoryClient
Returns Client object for InvoiceHistory endpoints.
106 107 108 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 106 def invoice_history @invoice_history end |
#invoices ⇒ InvoicesClient
Returns Client object for Invoices endpoints.
110 111 112 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 110 def invoices @invoices end |
#leads ⇒ LeadsClient
Returns Client object for Leads endpoints.
114 115 116 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 114 def leads @leads end |
#notes ⇒ NotesClient
Returns Client object for Notes endpoints.
118 119 120 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 118 def notes @notes end |
#payment_applications ⇒ PaymentApplicationsClient
Returns Client object for PaymentApplications endpoints.
122 123 124 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 122 def payment_applications @payment_applications end |
#payments ⇒ PaymentsClient
Returns Client object for Payments endpoints.
126 127 128 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 126 def payments @payments end |
#provisioning ⇒ ProvisioningClient
Returns Client object for Provisioning endpoints.
130 131 132 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 130 def provisioning @provisioning end |
#reports ⇒ ReportsClient
Returns Client object for Reports endpoints.
134 135 136 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 134 def reports @reports end |
#status ⇒ StatusClient
Returns Client object for Status endpoints.
138 139 140 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 138 def status @status end |
#sync ⇒ SyncClient
Returns Client object for Sync endpoints.
142 143 144 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 142 def sync @sync end |
#user_accounts ⇒ UserAccountsClient
Returns Client object for UserAccounts endpoints.
146 147 148 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 146 def user_accounts @user_accounts end |
#user_roles ⇒ UserRolesClient
Returns Client object for UserRoles endpoints.
150 151 152 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 150 def user_roles @user_roles end |
#version ⇒ String
Returns The version number of this Lockstep API client.
30 31 32 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 30 def version @version end |
#webhooks ⇒ WebhooksClient
Returns Client object for Webhooks endpoints.
154 155 156 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 154 def webhooks @webhooks end |
Instance Method Details
#request(method, path, body, params) ⇒ Object
Send a request to the API and return the results
Sends a request to the
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 235 def request(method, path, body, params) url = URI(@env + path) if !params.nil? url.query = URI.encode_www_form(params) end http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = case method when :get Net::HTTP::Get.new(url) when :post Net::HTTP::Post.new(url) when :patch Net::HTTP::Patch.new(url) when :put Net::HTTP::Put.new(url) when :delete Net::HTTP::Delete.new(url) end # Set headers and body for request request["Accept"] = 'application/json' request["Content-Type"] = 'application/*+json' request["SdkType"] = 'Ruby' request["SdkVersion"] = '2022.9.6.0' request["MachineName"] = Socket.gethostname request.body = body # If there is an application name if @app_name != nil request["ApplicationName"] = @app_name end # Which authentication are we using? if @api_key != nil request["Api-Key"] = @api_key end if @bearer_token != nil request["Authorization"] = 'Bearer ' + @bearer_token end # Send the request response = http.request(request) response.read_body end |
#with_api_key(api_key) ⇒ Object
Configure this API client to use API key authentication
209 210 211 212 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 209 def with_api_key(api_key) @bearer_token = nil @api_key = api_key end |
#with_app_name(app_name) ⇒ Object
Configure this API to use an application name
227 228 229 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 227 def with_app_name(app_name) @app_name = app_name end |
#with_bearer_token(bearer_token) ⇒ Object
Configure this API client to use JWT Bearer Token authentication
218 219 220 221 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 218 def with_bearer_token(bearer_token) @api_key = nil @bearer_token = bearer_token end |