Class: Flydata::SourceZendesk::SyncGenerateTableDdl

Inherits:
Flydata::Source::SyncGenerateTableDdl show all
Defined in:
lib/flydata/source_zendesk/sync_generate_table_ddl.rb,
lib/flydata/source_zendesk/zendesk_flydata_tabledefs.rb

Constant Summary collapse

ZENDESK_FLYDATA_TABLEDEFS =
{"tickets"=>
  {:table_name=>"tickets",
   :columns=>
    [{:column=>"id", :type=>"int8(20)", :not_null=>true, :primary_key=>true},
     {:column=>"url", :type=>"varchar(8000)", :default=>nil},#RFC7231 8000 octets
     {:column=>"external_id", :type=>"varchar(2047)", :default=>nil},
     {:column=>"type", :type=>"varchar(24)", :default=>nil},
     {:column=>"subject", :type=>"text"},
     {:column=>"raw_subject", :type=>"text"},
     {:column=>"description", :type=>"text"},
     {:column=>"priority", :type=>"varchar(24)", :default=>nil},
     {:column=>"status", :type=>"varchar(24)", :default=>nil},
     {:column=>"recipient", :type=>"varchar(762)", :default=>nil},#email
     {:column=>"requester_id", :type=>"int8(20)", :default=>nil},
     {:column=>"submitter_id", :type=>"int8(20)", :default=>nil},
     {:column=>"assignee_id", :type=>"int8(20)", :default=>nil},
     {:column=>"organization_id", :type=>"int8(20)", :default=>nil},
     {:column=>"group_id", :type=>"int8(20)", :default=>nil},
     {:column=>"collaborator_ids", :type=>"text"},
     {:column=>"forum_topic_id", :type=>"int8(20)", :default=>nil},
     {:column=>"problem_id", :type=>"int8(20)", :default=>nil},
     {:column=>"has_incidents", :type=>"int1(1)", :default=>nil},
     {:column=>"due_at", :type=>"datetime", :default=>nil},
     {:column=>"tags", :type=>"text"},
     {:column=>"via", :type=>"text"},
     {:column=>"custom_fields", :type=>"text"},
     {:column=>"satisfaction_rating", :type=>"text"},
     {:column=>"sharing_agreement_ids", :type=>"text"},
     {:column=>"followup_ids", :type=>"text"},
     {:column=>"ticket_form_id", :type=>"int8(20)", :default=>nil},
     {:column=>"brand_id", :type=>"int8(20)", :default=>nil},
     {:column=>"created_at", :type=>"datetime", :default=>nil},
     {:column=>"updated_at", :type=>"datetime", :default=>nil}],
   :default_charset=>"UTF_8",
   :src_ddl=> '{"version":"Zendesk v2 API","url":"https://developer.zendesk.com/rest_api/docs/core/tickets”}'
  },
 "ticket_comments"=>
  {:table_name=>"ticket_comments",
   :columns=>
    [{:column=>"id", :type=>"int8(20)", :not_null=>true, :primary_key=>true},
     {:column=>"type", :type=>"varchar(24)", :default=>nil},
     {:column=>"body", :type=>"text"},
     {:column=>"html_body", :type=>"text"},
     {:column=>"public", :type=>"int1(1)", :default=>nil},
     {:column=>"author_id", :type=>"int8(20)", :default=>nil},
     {:column=>"attachments", :type=>"text"},
     {:column=>"via", :type=>"text"},
     {:column=>"metadata", :type=>"text"},
     {:column=>"created_at", :type=>"datetime", :default=>nil}],
   :default_charset=>"UTF_8",
   :src_ddl=> '{"version":"Zendesk v2 API","url":"https://developer.zendesk.com/rest_api/docs/core/ticket_comments”}'
  },
 "ticket_audits"=>
  {:table_name=>"ticket_audits",
   :columns=>
    [{:column=>"id", :type=>"int8(20)", :not_null=>true, :primary_key=>true},
     {:column=>"ticket_id", :type=>"int8(20)", :default=>nil},
     {:column=>"metadata", :type=>"text"},
     {:column=>"via", :type=>"text"},
     {:column=>"created_at", :type=>"datetime", :default=>nil},
     {:column=>"author_id", :type=>"int8(20)", :default=>nil},
     {:column=>"events", :type=>"text"}],
   :default_charset=>"UTF_8",
   :src_ddl=> '{"version":"Zendesk v2 API","url":"https://developer.zendesk.com/rest_api/docs/core/ticket_audits”}'
  },
 "users"=>
  {:table_name=>"users",
   :columns=>
    [{:column=>"id", :type=>"int8(20)", :not_null=>true, :primary_key=>true},
     {:column=>"url", :type=>"varchar(8000)", :default=>nil},#RFC 7230 recommendation (8000 octets)
     {:column=>"name", :type=>"varchar(6141)", :default=>nil},
     {:column=>"external_id", :type=>"varchar(2047)", :default=>nil},
     {:column=>"alias", :type=>"varchar(6141)", :default=>nil},
     {:column=>"created_at", :type=>"datetime", :default=>nil},
     {:column=>"updated_at", :type=>"datetime", :default=>nil},
     {:column=>"active", :type=>"int1(1)", :default=>nil},
     {:column=>"verified", :type=>"int1(1)", :default=>nil},
     {:column=>"shared", :type=>"int1(1)", :default=>nil},
     {:column=>"shared_agent", :type=>"int1(1)", :default=>nil},
     {:column=>"locale", :type=>"varchar(765)", :default=>nil},
     {:column=>"locale_id", :type=>"int4(11)", :default=>nil},
     {:column=>"time_zone", :type=>"varchar(765)", :default=>nil},
     {:column=>"last_login_at", :type=>"datetime", :default=>nil},
     {:column=>"two_factor_auth_enabled", :type=>"int1(1)", :default=>nil},
     {:column=>"email", :type=>"varchar(762)", :default=>nil},
     {:column=>"phone", :type=>"varchar(765)", :default=>nil},
     {:column=>"signature", :type=>"text"},
     {:column=>"details", :type=>"text"},
     {:column=>"notes", :type=>"text"},
     {:column=>"organization_id", :type=>"int8(20)", :default=>nil},
     {:column=>"role", :type=>"varchar(24)", :default=>nil},
     {:column=>"custom_role_id", :type=>"int8(20)", :default=>nil},
     {:column=>"moderator", :type=>"int1(1)", :default=>nil},
     {:column=>"ticket_restriction", :type=>"varchar(24)", :default=>nil},
     {:column=>"only_private_comments", :type=>"int1(1)", :default=>nil},
     {:column=>"tags", :type=>"text"},
     {:column=>"suspended", :type=>"int1(1)", :default=>nil},
     {:column=>"restricted_agent", :type=>"int1(1)", :default=>nil},
     {:column=>"photo", :type=>"text"},
     {:column=>"user_fields", :type=>"text"}],
   :default_charset=>"UTF_8",
   :src_ddl=> '{"version":"Zendesk v2 API","url":"https://developer.zendesk.com/rest_api/docs/core/users”}'
  },
 "organizations"=>
  {:table_name=>"organizations",
   :columns=>
    [{:column=>"id", :type=>"int8(20)", :not_null=>true, :primary_key=>true},
     {:column=>"url", :type=>"varchar(8000)", :default=>nil},
     {:column=>"external_id", :type=>"varchar(2047)", :default=>nil},
     {:column=>"name", :type=>"varchar(6141)", :default=>nil},
     {:column=>"created_at", :type=>"datetime", :default=>nil},
     {:column=>"updated_at", :type=>"datetime", :default=>nil},
     {:column=>"domain_names", :type=>"text"},
     {:column=>"details", :type=>"text"},
     {:column=>"notes", :type=>"text"},
     {:column=>"group_id", :type=>"int8(20)", :default=>nil},
     {:column=>"shared_tickets", :type=>"int1(1)", :default=>nil},
     {:column=>"shared_comments", :type=>"int1(1)", :default=>nil},
     {:column=>"tags", :type=>"text"},
     {:column=>"organization_fields", :type=>"text"}],
   :default_charset=>"UTF_8",
   :src_ddl=> '{"version":"Zendesk v2 API","url":"https://developer.zendesk.com/rest_api/docs/core/organizations”}'
  }
}

Instance Attribute Summary

Attributes inherited from Flydata::Source::SyncGenerateTableDdl

#dp

Instance Method Summary collapse

Methods inherited from Flydata::Source::SyncGenerateTableDdl

inherited, #initialize

Methods inherited from Flydata::Source::Component

#initialize

Constructor Details

This class inherits a constructor from Flydata::Source::SyncGenerateTableDdl

Instance Method Details

#generate_flydata_tabledef(tables, options) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/flydata/source_zendesk/sync_generate_table_ddl.rb', line 12

def generate_flydata_tabledef(tables, options)
  flydata_tabledefs = []
  error_list = []
  zendesk_resource_names = ZENDESK_FLYDATA_TABLEDEFS.keys.join(" ")

  tables.each do |tablename|
    flydata_tabledef = ZENDESK_FLYDATA_TABLEDEFS[tablename]
    if !flydata_tabledef
      error_list << { error: "Invalid Zendesk resource name specified. Flydata supports following Zendesk resources: #{zendesk_resource_names}", table: tablename }
      next
    end
    flydata_tabledefs << flydata_tabledef
  end
  [flydata_tabledefs, error_list]
end

#run_compatibility_checkObject



8
9
10
# File 'lib/flydata/source_zendesk/sync_generate_table_ddl.rb', line 8

def run_compatibility_check
  #TODO Check version "Zendesk v2 API"
end