{"id":13546372,"url":"https://github.com/lucidnz/lib-ruby-lucid-shopify","last_synced_at":"2025-04-14T05:17:08.120Z","repository":{"id":14222237,"uuid":"16929160","full_name":"lucidnz/lib-ruby-lucid-shopify","owner":"lucidnz","description":"Basic interfaces to the Shopify API.","archived":false,"fork":false,"pushed_at":"2020-03-08T02:49:15.000Z","size":48,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":15,"default_branch":"master","last_synced_at":"2024-11-03T14:35:40.616Z","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/lucidnz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-02-17T22:44:11.000Z","updated_at":"2021-01-29T20:44:58.000Z","dependencies_parsed_at":"2022-09-03T10:01:16.836Z","dependency_job_id":null,"html_url":"https://github.com/lucidnz/lib-ruby-lucid-shopify","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/lucidnz%2Flib-ruby-lucid-shopify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucidnz%2Flib-ruby-lucid-shopify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucidnz%2Flib-ruby-lucid-shopify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucidnz%2Flib-ruby-lucid-shopify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lucidnz","download_url":"https://codeload.github.com/lucidnz/lib-ruby-lucid-shopify/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226798080,"owners_count":17683672,"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-08-01T12:00:36.000Z","updated_at":"2024-11-27T17:59:54.671Z","avatar_url":"https://github.com/lucidnz.png","language":"Ruby","funding_links":[],"categories":["Libraries","库"],"sub_categories":["Ruby"],"readme":"lucid_shopify\n=============\n\n`lucid_shopify` provides basic interfaces to the Shopify API including\nauthentication, validation, webhooks, billing and a small subset of common API\ncalls. Each interface is designed for extension and provides only a base from\nwhich to start.\n\nIt is designed around my own workflows and experiences and is not intended to\ncover every possible scenario. It is also unstable and subject to change as I\nfigure out the details.\n\n\nExamples\n--------\n\n### Authentication\n\nAuthentication is handled by `LucidShopify::Authenticate`. All you need is\nthe shop handle/URI. See the source documentation for details.\n\n\n### Billing\n\nBilling requires implementation of a `plan` interface responding to `#handle`\nand `#price`. For example:\n\n    class Plan \u003c Struct.new( :handle, :price )\n\n      # ...\n\n    end\n\nWith this, you can create a recurring application charge with `#subscribe`.\nIf successful, this will return a confirmation URI with which to redirect the\nshop owner so they may accept of decline a charge. Ensure that you've set\n`:billing_uri` in `LucidShopify.config` as this is where the shop owner will\nreturn to your app.\n\n    confirmation_uri = billing_api.subscribe( plan )\n\nWhen the user returns, the request params should include `id`, which you\nshould pass to `#process_subscription`. If the shop owner accepted, this will\nactivate the charge. If the shop owner declined, this will return `nil`.\n\n    billing_api.process_subscription( charge_id )\n\nTo unsubscribe, pass the `charge_id` to `#unsubscribe` (so keep track of\nthat `id`).\n\n\n### Resource Mappings\n\nGenerally, interfaces to remote resources will be used with resource mappings\nwhich are provided by `lucid_client`. The following example illustrates how\nthis might be achieved.\n\nFirst we implement a model with the `LucidClient::Model` interface:\n\n    class Product\n\n      include LucidClient::Model\n\n      map_resources do\n        { :name =\u003e 'title', :description =\u003e 'body_html' }\n      end\n\n    end\n\nThen we subclass the API and override the `#all` and `#_fields` methods:\n\n    class ProductAPI \u003c LucidShopify::ProductAPI\n\n      def all( params = {} )\n        represent_each super( params )\n      end\n\n      private\n\n      def _model\n        ::Product\n      end\n\n    end\n\nActually ... this second step is no longer necessary (but still serves as a\nnice example of wrapping the calls in subclasses) and now all that is needed\nis to set `config[:product_model]` which expects a callable:\n\n    LucidShopify.config[:product_model] = -\u003e { ::Product }\n\n\n### Webhook Verification\n\nWhen handling webhook requests, you'll almost always want to verify the source\nof the request. This can be done with `LucidShopify::Policies::ValidWebhook`\nwhich checks the request signature to ensure that the request originated from\nShopify.\n\n    LucidShopify::Policies::ValidWebhook.new( request ).valid?\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucidnz%2Flib-ruby-lucid-shopify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flucidnz%2Flib-ruby-lucid-shopify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucidnz%2Flib-ruby-lucid-shopify/lists"}