diff --git a/custom_connectors/oauth2/joinit_connector.rb b/custom_connectors/oauth2/joinit_connector.rb new file mode 100644 index 00000000..832a6e4e --- /dev/null +++ b/custom_connectors/oauth2/joinit_connector.rb @@ -0,0 +1,527 @@ +{ + title: 'Join It', + + connection: { + authorization: { + type: 'oauth2', + + authorization_url: ->() { + 'https://www.joinit.org/oauth2/authorize' + }, + + token_url: ->() { + 'https://www.joinit.org/oauth2/token' + }, + + client_id: 'kDtzwG9stDLqGmkCi', + + client_secret: 'CYY9U/PgyI8YwoZeJxQztA==', + + credentials: ->(connection, access_token) { + headers('Authorization': "Bearer #{access_token}") + } + } + }, + + test: ->(connection) { + get("https://www.joinit.org/api/v1/organizations/me/details") + }, + + object_definitions: { + + organizations: { + + fields: ->() { + [ + { + name: '_id', + }, + { + name: 'name', + } + ] + }, + + }, + + memberships: { + + fields: ->() { + [ + { + name: '_id', + label: "Unique ID of Membership Object", + hint: "Internal ID for Join It. Will always be unique." + }, + { + name: 'email', + label: "Email Address of Membership", + hint: "Email Address associated with Membership. Can be NULL.", + control_type: 'email' + }, + { + name: 'members_id', + label: "ID of Members Object", + hint: "Internal ID for Join It. Will not always be unique. Will be duplicated when multiple memberships are associated with the same Member login." + }, + { + name: 'groups_id', + label: "ID of Groups Object", + hint: "Internal ID of Groups. Will often be undefined or null." + }, + { + name: 'external_id', + label: "ID of Membership defined by Organization", + hint: "ID of Membership Defined by Organization." + }, + { + name: 'display_name', + label: "Display Name of Membership", + hint: "Display Name of Membership. Determined by Organization's Settings." + }, + { + name: 'organization_id', + label: "Internal ID of Organization", + hint: "Internal ID of Organization. Unique to the Organzation." + }, + { + name: 'expiration_date', + label: "Expiration Date of Membership", + hint: "Expiration Date of Membership. Can be NULL for automatically re-billing memberships." + }, + { + name: 'membership_type', + label: "ID of Membership Type", + hint: "Interal ID of Membership Type" + }, + { + name: 'membership_name', + label: "Name of Membership Type", + hint: "Name of Membership Type." + }, + { + name: 'status', + label: "Status of Membership", + hint: "Status of Membership. Can be: 50 - prospective, 75 - pending, 100 - active, 300 - expired, 350 - cancelled." + }, + { + name: 'notes', + label: "Notes associated with the Membership", + hint: "Notes associated with the Membership" + }, + { + name: "customer_id", + label: "Stripe Customer ID", + hint: "Customer ID generated by Stripe and associated with this Membership (not unique)" + }, + { + name: 'subscription_id', + label: "Stripe Subscription ID", + hint: "Subscription ID generated by Stripe and associated with this Membership (not unique)" + }, + { + name: 'custom_answers', + label: "Custom Answers associated with the Membership", + hint: "Custom Answers associated with the Membership", + type: "array", + of: "object", + properties: [ + { + name: "custom_answers", + type: "object", + properties: [ + { + name: "question_id", + label: "ID of Question" + }, + { + name: "question", + label: "Question" + }, + { + name: "answer", + label: "Answer" + } + ] + } + ] + }, + { + name: 'profile', + label: "Profile Information for the Membership", + hint: "Profile Information for the Membership", + type: "object", + properties: [ + { + name: "first_name" + }, + { + name: "last_name" + }, + { + name: "gender" + }, + { + name: "birthday" + }, + { + name: "company" + }, + { + name: "job_title" + }, + { + name: "phone" + }, + { + name: "company" + }, + { + name: "twitter" + }, + { + name: "linkedin" + }, + { + name: "facebook" + }, + { + name: "address", + type: "object", + properties: [ + { + name: "street", + label: "Street Address" + }, + { + name: "city", + label: "City" + }, + { + name: "zip", + label: "Zip or Postal" + }, + { + name: "region", + label: "Region Code" + }, + { + name: "country", + label: "ISO Country Code" + } + ] + } + ] + }, + { + name: 'md5hash' + } + ] + } + }, + + journals: { + + fields: ->() { + [ + { + name: '_id', + label: "ID of Payment", + hint: "ID used internally by Join It" + }, + { + name: 'external_id', + label: "Invoice ID", + hint: "Inoive ID editable by Organizations" + }, + { + name: 'stripe_charge_id', + label: "Stripe Charge ID", + hint: "Unique ID for Stripe Charge" + }, + { + name: 'organization_id', + label: "Organization ID" + }, + { + name: 'amount', + label: "Amount of Payment", + hint: "Value is Base 100 Number System, e.g. $1 is 100" + }, + { + name: 'currency', + label: "Currency of Payment", + hint: "3-Letter ISO Code for Currency of Payment" + }, + { + name: 'subscription_id', + label: "Stripe Subscription ID", + hint: "Unique ID associated with Subscription Object in connected Stripe account" + }, + { + name: 'payment_date', + label: "Date of Payment", + hint: "Date of Payment" + }, + { + name: "member_id", + label: "Member ID", + hint: "ID of associated Member" + }, + { + name: "membership_id", + label: "Membership ID", + hint: "ID of associated Membership" + }, + { + name: 'channel', + label: "Channel of Payment", + hint: "Channel where payment was captured - e.g. admin, stripe" + } + ] + } + } + + }, + + actions: { + + get_organization: { + input_fields: ->(object_definitions) { + }, + + execute: ->(connection, input) { + get("https://www.joinit.org/api/v1/organizations/me/details", { } ) + }, + + # Output schema. Same as input above. + output_fields: ->(object_definitions) { + object_definitions['organizations'] + } + }, + + get_membership: { + + input_fields: ->(object_definitions) { + + }, + + execute: ->(connection, input) { + + get("https://www.joinit.org/api/v1/organizations/me/memberships", { } ) + + }, + + + output_fields: ->(object_definitions) { + + object_definitions[ 'memberships' ] + + } + }, + }, + + triggers: { + + new_memberships: { + + webhook_subscribe: ->(webhook_url, connection, input, recipe_id) { + post("https://www.joinit.org/api/v1/organizations/me/webhooks", + name: "Workato recipe #{recipe_id}", + app_name: "workato", + object_id: webhook_url, + resource: "memberships", + event: "created") + }, + + webhook_unsubscribe: ->(webhook) { + delete("https://www.joinit.org/api/v1/organizations/me/webhooks?_id=#{webhook['_id']}") + }, + + dedup: ->(memberships) { + memberships['_id'] + }, + + webhook_notification: ->(input, payload) { + payload + }, + + output_fields: ->(object_definitions) { + object_definitions['memberships'] + } + }, + + updated_memberships: { + + webhook_subscribe: ->(webhook_url, connection, input, recipe_id) { + post("https://www.joinit.org/api/v1/organizations/me/webhooks", + name: "Workato recipe #{recipe_id}", + app_name: "workato", + object_id: webhook_url, + resource: "memberships", + event: "updated") + }, + + webhook_unsubscribe: ->(webhook) { + delete("https://www.joinit.org/api/v1/organizations/me/webhooks?_id=#{webhook['_id']}") + }, + + dedup: ->(memberships) { + memberships['_id'] + }, + + webhook_notification: ->(input, payload) { + payload + }, + + output_fields: ->(object_definitions) { + object_definitions['memberships'] + } + }, + + updated_memberships_renewal: { + + webhook_subscribe: ->(webhook_url, connection, input, recipe_id) { + post("https://www.joinit.org/api/v1/organizations/me/webhooks", + name: "Workato recipe #{recipe_id}", + app_name: "workato", + object_id: webhook_url, + resource: "memberships", + event: "renewal") + }, + + webhook_unsubscribe: ->(webhook) { + delete("https://www.joinit.org/api/v1/organizations/me/webhooks?_id=#{webhook['_id']}") + }, + + dedup: ->(memberships) { + memberships['_id'] + }, + + webhook_notification: ->(input, payload) { + payload + }, + + output_fields: ->(object_definitions) { + object_definitions['memberships'] + } + }, + + updated_memberships_email: { + + webhook_subscribe: ->(webhook_url, connection, input, recipe_id) { + post("https://www.joinit.org/api/v1/organizations/me/webhooks", + name: "Workato recipe #{recipe_id}", + app_name: "workato", + object_id: webhook_url, + resource: "memberships", + event: "email-updated") + }, + + webhook_unsubscribe: ->(webhook) { + delete("https://www.joinit.org/api/v1/organizations/me/webhooks?_id=#{webhook['_id']}") + }, + + dedup: ->(memberships) { + memberships['_id'] + }, + + webhook_notification: ->(input, payload) { + payload + }, + + output_fields: ->(object_definitions) { + object_definitions['memberships'] + } + }, + + updated_memberships_inactive: { + + webhook_subscribe: ->(webhook_url, connection, input, recipe_id) { + post("https://www.joinit.org/api/v1/organizations/me/webhooks", + name: "Workato recipe #{recipe_id}", + app_name: "workato", + object_id: webhook_url, + resource: "memberships", + event: "inactive") + }, + + webhook_unsubscribe: ->(webhook) { + delete("https://www.joinit.org/api/v1/organizations/me/webhooks?_id=#{webhook['_id']}") + }, + + dedup: ->(memberships) { + memberships['_id'] + }, + + webhook_notification: ->(input, payload) { + payload + }, + + output_fields: ->(object_definitions) { + object_definitions['memberships'] + } + }, + + new_payments: { + + webhook_subscribe: ->(webhook_url, connection, input, recipe_id) { + post("https://www.joinit.org/api/v1/organizations/me/webhooks", + name: "Workato recipe #{recipe_id}", + app_name: "workato", + object_id: webhook_url, + resource: "payments", + event: "created") + }, + + webhook_unsubscribe: ->(webhook) { + delete("https://www.joinit.org/api/v1/organizations/me/webhooks?_id=#{webhook['_id']}") + }, + + dedup: ->(journals) { + journals['_id'] + }, + + webhook_notification: ->(input, payload) { + payload["data"] + }, + + output_fields: ->(object_definitions) { + object_definitions['journals'] + } + }, + + refunded_payments: { + + webhook_subscribe: ->(webhook_url, connection, input, recipe_id) { + post("https://www.joinit.org/api/v1/organizations/me/webhooks", + name: "Workato recipe #{recipe_id}", + app_name: "workato", + object_id: webhook_url, + resource: "payments", + event: "refunded") + }, + + webhook_unsubscribe: ->(webhook) { + delete("https://www.joinit.org/api/v1/organizations/me/webhooks?_id=#{webhook['_id']}") + }, + + dedup: ->(journals) { + journals['_id'] + }, + + webhook_notification: ->(input, payload) { + payload["data"] + }, + + output_fields: ->(object_definitions) { + object_definitions['journals'] + } + } + + }, + + pick_lists: { + + }, +}