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.
-
#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.
Class Method Summary collapse
-
.new(env) ⇒ Object
Construct a new Lockstep API client targeting the specified server.
Instance Method Summary collapse
-
#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_bearer_token(bearer_token) ⇒ Object
Configure this API client to use JWT Bearer Token authentication.
Instance Attribute Details
#activities ⇒ ActivitiesClient
Returns Client object for Activities endpoints.
34 35 36 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 34 def activities @activities end |
#api_keys ⇒ ApiKeysClient
Returns Client object for ApiKeys endpoints.
36 37 38 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 36 def api_keys @api_keys end |
#app_enrollments ⇒ AppEnrollmentsClient
Returns Client object for AppEnrollments endpoints.
38 39 40 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 38 def app_enrollments @app_enrollments end |
#applications ⇒ ApplicationsClient
Returns Client object for Applications endpoints.
40 41 42 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 40 def applications @applications end |
#attachments ⇒ AttachmentsClient
Returns Client object for Attachments endpoints.
42 43 44 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 42 def @attachments end |
#code_definitions ⇒ CodeDefinitionsClient
Returns Client object for CodeDefinitions endpoints.
44 45 46 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 44 def code_definitions @code_definitions end |
#companies ⇒ CompaniesClient
Returns Client object for Companies endpoints.
46 47 48 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 46 def companies @companies end |
#contacts ⇒ ContactsClient
Returns Client object for Contacts endpoints.
48 49 50 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 48 def contacts @contacts end |
#credit_memo_applied ⇒ CreditMemoAppliedClient
Returns Client object for CreditMemoApplied endpoints.
50 51 52 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 50 def credit_memo_applied @credit_memo_applied end |
#currencies ⇒ CurrenciesClient
Returns Client object for Currencies endpoints.
52 53 54 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 52 def currencies @currencies end |
#custom_field_definitions ⇒ CustomFieldDefinitionsClient
Returns Client object for CustomFieldDefinitions endpoints.
54 55 56 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 54 def custom_field_definitions @custom_field_definitions end |
#custom_field_values ⇒ CustomFieldValuesClient
Returns Client object for CustomFieldValues endpoints.
56 57 58 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 56 def custom_field_values @custom_field_values end |
#definitions ⇒ DefinitionsClient
Returns Client object for Definitions endpoints.
58 59 60 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 58 def definitions @definitions end |
#emails ⇒ EmailsClient
Returns Client object for Emails endpoints.
60 61 62 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 60 def emails @emails end |
#env ⇒ String
Returns The name or URL of the environment.
32 33 34 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 32 def env @env end |
#invoice_history ⇒ InvoiceHistoryClient
Returns Client object for InvoiceHistory endpoints.
62 63 64 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 62 def invoice_history @invoice_history end |
#invoices ⇒ InvoicesClient
Returns Client object for Invoices endpoints.
64 65 66 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 64 def invoices @invoices end |
#leads ⇒ LeadsClient
Returns Client object for Leads endpoints.
66 67 68 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 66 def leads @leads end |
#notes ⇒ NotesClient
Returns Client object for Notes endpoints.
68 69 70 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 68 def notes @notes end |
#payment_applications ⇒ PaymentApplicationsClient
Returns Client object for PaymentApplications endpoints.
70 71 72 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 70 def payment_applications @payment_applications end |
#payments ⇒ PaymentsClient
Returns Client object for Payments endpoints.
72 73 74 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 72 def payments @payments end |
#provisioning ⇒ ProvisioningClient
Returns Client object for Provisioning endpoints.
74 75 76 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 74 def provisioning @provisioning end |
#reports ⇒ ReportsClient
Returns Client object for Reports endpoints.
76 77 78 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 76 def reports @reports end |
#status ⇒ StatusClient
Returns Client object for Status endpoints.
78 79 80 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 78 def status @status end |
#sync ⇒ SyncClient
Returns Client object for Sync endpoints.
80 81 82 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 80 def sync @sync end |
#user_accounts ⇒ UserAccountsClient
Returns Client object for UserAccounts endpoints.
82 83 84 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 82 def user_accounts @user_accounts end |
#user_roles ⇒ UserRolesClient
Returns Client object for UserRoles endpoints.
84 85 86 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 84 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 |
Class Method Details
.new(env) ⇒ Object
Construct a new Lockstep API client targeting the specified server.
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 89 def self.new(env) @version = "2022.3.49.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) @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) 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
148 149 150 151 152 153 154 155 156 157 158 159 160 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 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 148 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 request["Accept"] = 'application/json' request["Content-Type"] = 'application/*+json' # Convert the body to json if !body.nil? request.body = body.to_camelback_keys.to_json 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
132 133 134 135 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 132 def with_api_key(api_key) @bearer_token = nil @api_key = api_key end |
#with_bearer_token(bearer_token) ⇒ Object
Configure this API client to use JWT Bearer Token authentication
140 141 142 143 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 140 def with_bearer_token(bearer_token) @api_key = nil @bearer_token = bearer_token end |