{"id":18658290,"url":"https://github.com/musicglue/primer-api","last_synced_at":"2025-11-05T23:30:30.397Z","repository":{"id":146365033,"uuid":"21387767","full_name":"musicglue/primer-api","owner":"musicglue","description":null,"archived":false,"fork":false,"pushed_at":"2015-04-22T16:01:41.000Z","size":214,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":14,"default_branch":"master","last_synced_at":"2024-12-27T15:25:18.331Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/musicglue.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-07-01T13:00:52.000Z","updated_at":"2015-04-02T09:58:20.000Z","dependencies_parsed_at":"2023-03-28T20:31:05.289Z","dependency_job_id":null,"html_url":"https://github.com/musicglue/primer-api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/musicglue%2Fprimer-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/musicglue%2Fprimer-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/musicglue%2Fprimer-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/musicglue%2Fprimer-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/musicglue","download_url":"https://codeload.github.com/musicglue/primer-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239475962,"owners_count":19645041,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T07:32:17.801Z","updated_at":"2025-11-05T23:30:30.326Z","avatar_url":"https://github.com/musicglue.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PrimerApi\n\nThis is the counterpart for the Primer web application, it provides an ActiveRecord style interface to Primer.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\n  gem 'primer_api'\n```\n\nAnd then execute:\n\n```\n  $ bundle\n```\n\nOr install it yourself as:\n\n```\n  $ gem install primer_api\n```\n\nOnce you have it loaded you can run the rails generator to create the initializer file:\n\n```\n  $ rails g primer_api:initializer\n```\n\n## Configuration\n\nPrimerApi takes several config directives:\n```ruby\n  PrimerApi.configure do |config|\n    # You should only override this in development and staging, staging it will be https://primer-staging.musicglue.com\n    config.host       = 'https://primer.musicglue.com'\n\n    # This is required, primer_api will not function without it.\n    config.api_key    = 'your_api_key_here'\n\n    # This is required, primer_api will not function without it\n    config.api_secret = 'such_sekrets_much_private_wow'\n  end\n```\n\nApi keys can be obtained from the primer web application\n\n## Usage\n\nPrimerApi allows you to create, delete and update jobs stored on the primer web service.\n\n### Creating\n\nYou can create two types of scheduled jobs, a one off job `PrimerApi::SingleJob.new`, or a recurring job `PrimerApi::RecurringJob.new`.\nNB: You must call save in order for the job to get persisted to primer.\n\n#### Recurring\n\nWith a scheduled job you'll need to create an [ice_cube schedule](https://github.com/seejohnrun/ice_cube), and pass it in as the schedule attribute. For more information on ice_cube schedules please see the [ice_cube repository](https://github.com/seejohnrun/ice_cube)\n\n```ruby\n  job = PrimerApi::RecurringJob.new(schedule: scheudle, message_topic: :your_emmited_topic, payload: {data: :sent_back_in_the_notification})\n  if job.save\n    puts job.id #This is the unique job ID provided by primer, store it!\n  else\n    puts job.errors\n  end\n```\n\n#### Single\n\nSingle jobs take the same generic arguments as recurring jobs, `:message_topic, :payload`, however you pass in the date and time of the next occurrence directly.\n\n```ruby\n  job = PrimerApi::SingleJob.new(next_occurrence: 1.day.from_now, message_topic: :your_emmited_topic, payload: {data: :sent_back_in_the_notification})\n  if job.save\n    puts job.id #This is the unique job ID provided by primer, store it!\n  else\n    puts job.errors\n  end\n```\n\n##### Unique Single Jobs\n\nYou can enforce uniqueness on a ```SingleJob``` by specifying a string `:unique_key` value. This will ensure that is a job will only ever be created once.\n\n```ruby\njob = PrimerApi::SingleJob.new(unique_key: 'my_unique_key', next_occurrence: 1.day.from_now, message_topic: :your_emmited_topic, payload: {})\n```\n\n### Updating\n\nIn order to update you'll need to have the job ID that was returned during the save operation. Updates work very similarly for both types of job, you just have to supply the changed parameters.\n\n```ruby\n  job = PrimerApi::SingleJob.find(job_id)\n  job.next_occurrence = 3.days.from_now\n  job.save\n```\n\nThe job ID will remain the same.\n\n### Deleting\n\nDestroying a job is as simple as finding the job from the api, and calling destroy on it.\n\n```ruby\n  PrimerApi::SingleJob.find(job_id).destroy\n```\n\n## Contributing\n\n1. Fork it ( https://github.com/[my-github-username]/primer_api/fork )\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmusicglue%2Fprimer-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmusicglue%2Fprimer-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmusicglue%2Fprimer-api/lists"}